Class: Roodi::Checks::NameCheck
- Defined in:
- lib/roodi/checks/name_check.rb
Overview
Checking that a node’s name matches a pattern
Direct Known Subclasses
Constant Summary
Constants inherited from Check
Instance Attribute Summary collapse
-
#pattern ⇒ Object
Returns the value of attribute pattern.
Instance Method Summary collapse
Methods inherited from Check
#add_error, #end_file, #errors, #evaluate_end, #evaluate_node, #evaluate_node_end, #evaluate_node_start, #initialize, make, #position, #start_file
Constructor Details
This class inherits a constructor from Roodi::Checks::Check
Instance Attribute Details
#pattern ⇒ Object
Returns the value of attribute pattern.
8 9 10 |
# File 'lib/roodi/checks/name_check.rb', line 8 def pattern @pattern end |
Instance Method Details
#evaluate_start(node) ⇒ Object
10 11 12 13 |
# File 'lib/roodi/checks/name_check.rb', line 10 def evaluate_start(node) name = find_name(node) add_error "#{} name \"#{name}\" should match pattern #{@pattern.inspect}" unless name.to_s =~ @pattern end |
#find_name(node) ⇒ Object
15 16 17 |
# File 'lib/roodi/checks/name_check.rb', line 15 def find_name(node) node[1].class == Symbol ? node[1] : node[1].last end |