Class: Roodi::Checks::NameCheck

Inherits:
Check
  • Object
show all
Defined in:
lib/roodi/checks/name_check.rb

Direct Known Subclasses

ClassNameCheck, MethodNameCheck, ModuleNameCheck

Constant Summary

Constants inherited from Check

Check::NODE_TYPES

Instance Attribute Summary collapse

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

#patternObject

Returns the value of attribute pattern.



7
8
9
# File 'lib/roodi/checks/name_check.rb', line 7

def pattern
  @pattern
end

Instance Method Details

#evaluate_start(node) ⇒ Object



9
10
11
12
# File 'lib/roodi/checks/name_check.rb', line 9

def evaluate_start(node)
  name = find_name(node)
  add_error "#{message_prefix} name \"#{name}\" should match pattern #{@pattern.inspect}" unless name.to_s =~ @pattern
end