Class: ArchSpec::Rules::Naming::NameSelector
- Inherits:
-
Object
- Object
- ArchSpec::Rules::Naming::NameSelector
- Defined in:
- lib/archspec/rules/naming_rules.rb
Overview
Selects methods whose name matches a regex. A named capture in the regex
(such as (?requires constraint.
Instance Attribute Summary collapse
-
#regex ⇒ Object
readonly
Returns the value of attribute regex.
Instance Method Summary collapse
- #describe ⇒ Object
-
#initialize(regex) ⇒ NameSelector
constructor
A new instance of NameSelector.
- #match(definition) ⇒ Object
Constructor Details
#initialize(regex) ⇒ NameSelector
Returns a new instance of NameSelector.
60 61 62 63 64 |
# File 'lib/archspec/rules/naming_rules.rb', line 60 def initialize(regex) raise Error, "method_names matching expects a Regexp, got #{regex.inspect}" unless regex.is_a?(Regexp) @regex = regex end |
Instance Attribute Details
#regex ⇒ Object (readonly)
Returns the value of attribute regex.
58 59 60 |
# File 'lib/archspec/rules/naming_rules.rb', line 58 def regex @regex end |
Instance Method Details
#describe ⇒ Object
70 71 72 |
# File 'lib/archspec/rules/naming_rules.rb', line 70 def describe "matches #{regex.inspect}" end |
#match(definition) ⇒ Object
66 67 68 |
# File 'lib/archspec/rules/naming_rules.rb', line 66 def match(definition) regex.match(definition.name.to_s) end |