class Tailor::Rulers::MaxLineLengthRuler

Public Class Methods

new(config, options) click to toggle source
Calls superclass method Tailor::Ruler::new
# File lib/tailor/rulers/max_line_length_ruler.rb, line 6
def initialize(config, options)
  super(config, options)
  add_lexer_observers :ignored_nl, :nl
end

Public Instance Methods

ignored_nl_update(lexed_line, lineno, column) click to toggle source
# 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) click to toggle source

Checks to see if the line has more characters that given at +@config+.

@param [Fixnum] lexed_line The line to measure. @param [Fixnum] lineno Line the potential problem is on. @param [Fixnum] column Column the potential problem is on

# 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) click to toggle source
# 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