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 Method Summary collapse

Methods inherited from Check

#add_error, #end_file, #errors, #evaluate_end, #evaluate_node, #evaluate_node_end, #evaluate_node_start, #position, #start_file

Constructor Details

#initialize(interesting_nodes, pattern, message_prefix) ⇒ NameCheck

Returns a new instance of NameCheck.



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

def initialize(interesting_nodes, pattern, message_prefix)
  super()
  @interesting_nodes = interesting_nodes
  @pattern = pattern
  @message_prefix = message_prefix
end

Instance Method Details

#evaluate_start(node) ⇒ Object



17
18
19
20
# File 'lib/roodi/checks/name_check.rb', line 17

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

#interesting_nodesObject



13
14
15
# File 'lib/roodi/checks/name_check.rb', line 13

def interesting_nodes
  @interesting_nodes
end