Class: Guideline::LongLineChecker::LineChecker
- Inherits:
-
Object
- Object
- Guideline::LongLineChecker::LineChecker
- Defined in:
- lib/guideline/checkers/long_line_checker.rb
Instance Method Summary collapse
- #has_error? ⇒ Boolean
-
#initialize(line, options = {}) ⇒ LineChecker
constructor
A new instance of LineChecker.
- #length ⇒ Object
- #lineno ⇒ Object
- #max ⇒ Object
- #message ⇒ Object
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, = {}) @line = line @options = end |
Instance Method Details
#has_error? ⇒ Boolean
39 40 41 |
# File 'lib/guideline/checkers/long_line_checker.rb', line 39 def has_error? length > max end |
#length ⇒ Object
47 48 49 |
# File 'lib/guideline/checkers/long_line_checker.rb', line 47 def length @line.split(//).length - 1 end |
#lineno ⇒ Object
51 52 53 |
# File 'lib/guideline/checkers/long_line_checker.rb', line 51 def lineno @options[:lineno] end |
#max ⇒ Object
43 44 45 |
# File 'lib/guideline/checkers/long_line_checker.rb', line 43 def max @options[:max] || 80 end |
#message ⇒ Object
33 34 35 36 37 |
# File 'lib/guideline/checkers/long_line_checker.rb', line 33 def actual = "%3d" % length limit = "%3d" % max "Line length #{actual} should be less than #{limit} characters" end |