Class: Roodi::Checks::ClassNameCheck
- Defined in:
- lib/roodi/checks/class_name_check.rb
Overview
Checks a class name to make sure it matches the specified pattern.
Keeping to a consistent naming convention makes your code easier to read.
Constant Summary collapse
- DEFAULT_PATTERN =
/^[A-Z][a-zA-Z0-9]*$/
Constants inherited from Check
Roodi::Checks::Check::NODE_TYPES
Instance Method Summary collapse
- #find_name(node) ⇒ Object
-
#initialize(options = {}) ⇒ ClassNameCheck
constructor
A new instance of ClassNameCheck.
Methods inherited from NameCheck
#evaluate_start, #interesting_nodes
Methods inherited from Check
#add_error, #end_file, #errors, #evaluate_end, #evaluate_node, #evaluate_node_end, #evaluate_node_start, #evaluate_start, #position, #start_file
Constructor Details
#initialize(options = {}) ⇒ ClassNameCheck
Returns a new instance of ClassNameCheck.
11 12 13 14 |
# File 'lib/roodi/checks/class_name_check.rb', line 11 def initialize( = {}) pattern = ['pattern'] || DEFAULT_PATTERN super([:class], pattern, 'Class') end |
Instance Method Details
#find_name(node) ⇒ Object
16 17 18 |
# File 'lib/roodi/checks/class_name_check.rb', line 16 def find_name(node) node[1].class == Symbol ? node[1] : node[1].last end |