Class: Tailor::Rulers::MaxLineLengthRuler
- Inherits:
-
Tailor::Ruler
- Object
- Tailor::Ruler
- Tailor::Rulers::MaxLineLengthRuler
- Defined in:
- lib/tailor/rulers/max_line_length_ruler.rb
Instance Attribute Summary
Attributes inherited from Tailor::Ruler
Instance Method Summary collapse
- #ignored_nl_update(lexed_line, lineno, column) ⇒ Object
-
#initialize(config, options) ⇒ MaxLineLengthRuler
constructor
A new instance of MaxLineLengthRuler.
-
#measure(lexed_line, lineno, column) ⇒ Object
Checks to see if the line has more characters that given at @config.
- #nl_update(lexed_line, lineno, column) ⇒ Object
Methods inherited from Tailor::Ruler
#add_child_ruler, #problem_type, #problems
Methods included from Logger::Mixin
Constructor Details
#initialize(config, options) ⇒ MaxLineLengthRuler
Returns a new instance of MaxLineLengthRuler.
6 7 8 9 |
# File 'lib/tailor/rulers/max_line_length_ruler.rb', line 6 def initialize(config, ) super(config, ) add_lexer_observers :ignored_nl, :nl end |
Instance Method Details
#ignored_nl_update(lexed_line, lineno, column) ⇒ Object
11 12 13 14 |
# File 'lib/tailor/rulers/max_line_length_ruler.rb', line 11 def ignored_nl_update(lexed_line, lineno, column) log "<#{self.class}> Line length: #{lexed_line.line_length}" measure(lexed_line, lineno, column) end |
#measure(lexed_line, lineno, column) ⇒ Object
Checks to see if the line has more characters that given at @config.
25 26 27 28 29 30 31 32 33 |
# File 'lib/tailor/rulers/max_line_length_ruler.rb', line 25 def measure(lexed_line, lineno, column) if lexed_line.line_length > @config msg = "Line is #{lexed_line.line_length} chars long, " msg << "but should be #{@config}." @problems << Problem.new(problem_type, lineno, column, msg, @options[:level]) end end |
#nl_update(lexed_line, lineno, column) ⇒ Object
16 17 18 |
# File 'lib/tailor/rulers/max_line_length_ruler.rb', line 16 def nl_update(lexed_line, lineno, column) ignored_nl_update(lexed_line, lineno, column) end |