Class: Tailor::Rulers::AllowCamelCaseMethodsRuler
- Inherits:
-
Tailor::Ruler
- Object
- Tailor::Ruler
- Tailor::Rulers::AllowCamelCaseMethodsRuler
- Defined in:
- lib/tailor/rulers/allow_camel_case_methods_ruler.rb
Instance Attribute Summary
Attributes inherited from Tailor::Ruler
Instance Method Summary collapse
- #ident_update(token, lexed_line, lineno, column) ⇒ Object
-
#initialize(style, options) ⇒ AllowCamelCaseMethodsRuler
constructor
A new instance of AllowCamelCaseMethodsRuler.
-
#measure(token, lineno, column) ⇒ Object
Checks to see if the method name contains capital letters.
Methods inherited from Tailor::Ruler
#add_child_ruler, #problem_type, #problems
Methods included from Logger::Mixin
Constructor Details
#initialize(style, options) ⇒ AllowCamelCaseMethodsRuler
Returns a new instance of AllowCamelCaseMethodsRuler.
6 7 8 9 |
# File 'lib/tailor/rulers/allow_camel_case_methods_ruler.rb', line 6 def initialize(style, ) super(style, ) add_lexer_observers :ident end |
Instance Method Details
#ident_update(token, lexed_line, lineno, column) ⇒ Object
11 12 13 14 15 16 17 18 19 20 21 |
# File 'lib/tailor/rulers/allow_camel_case_methods_ruler.rb', line 11 def ident_update(token, lexed_line, lineno, column) ident_index = lexed_line.event_index(column) previous_event = lexed_line.event_at(ident_index - 2) log "previous event: #{previous_event}" return if previous_event.nil? if previous_event[1] == :on_kw && previous_event.last == "def" measure(token, lineno, column) end end |
#measure(token, lineno, column) ⇒ Object
Checks to see if the method name contains capital letters.
28 29 30 31 32 33 34 35 |
# File 'lib/tailor/rulers/allow_camel_case_methods_ruler.rb', line 28 def measure(token, lineno, column) if token.contains_capital_letter? = "Camel-case method name found." @problems << Problem.new(problem_type, lineno, column, , @options[:level]) end end |