Class: Guideline::LongLineChecker::LineChecker

Inherits:
Object
  • Object
show all
Defined in:
lib/guideline/checkers/long_line_checker.rb

Instance Method Summary collapse

Constructor Details

#initialize(line, options = {}) ⇒ LineChecker

Returns a new instance of LineChecker.



28
29
30
31
# File 'lib/guideline/checkers/long_line_checker.rb', line 28

def initialize(line, options = {})
  @line    = line
  @options = options
end

Instance Method Details

#has_error?Boolean

Returns:

  • (Boolean)


39
40
41
# File 'lib/guideline/checkers/long_line_checker.rb', line 39

def has_error?
  length > max
end

#lengthObject



47
48
49
# File 'lib/guideline/checkers/long_line_checker.rb', line 47

def length
  @line.split(//).length - 1
end

#linenoObject



51
52
53
# File 'lib/guideline/checkers/long_line_checker.rb', line 51

def lineno
  @options[:lineno]
end

#maxObject



43
44
45
# File 'lib/guideline/checkers/long_line_checker.rb', line 43

def max
  @options[:max] || 80
end

#messageObject



33
34
35
36
37
# File 'lib/guideline/checkers/long_line_checker.rb', line 33

def message
  actual = "%3d" % length
  limit  = "%3d" % max
  "Line length #{actual} should be less than #{limit} characters"
end