Class: Tailor::Rulers::AllowTrailingLineSpacesRuler
- Inherits:
-
Tailor::Ruler
- Object
- Tailor::Ruler
- Tailor::Rulers::AllowTrailingLineSpacesRuler
- Defined in:
- lib/tailor/rulers/allow_trailing_line_spaces_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) ⇒ AllowTrailingLineSpacesRuler
constructor
A new instance of AllowTrailingLineSpacesRuler.
-
#measure(lexed_line, lineno, column) ⇒ Object
Checks to see if the line contains trailing spaces.
- #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) ⇒ AllowTrailingLineSpacesRuler
Returns a new instance of AllowTrailingLineSpacesRuler.
6 7 8 9 |
# File 'lib/tailor/rulers/allow_trailing_line_spaces_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 15 16 |
# File 'lib/tailor/rulers/allow_trailing_line_spaces_ruler.rb', line 11 def ignored_nl_update(lexed_line, lineno, column) log "Last event: #{lexed_line.last_non_line_feed_event}" log "Line ends with space: #{lexed_line.ends_with_sp?}" measure(lexed_line, lineno, column) end |
#measure(lexed_line, lineno, column) ⇒ Object
Checks to see if the line contains trailing spaces.
27 28 29 30 31 32 33 34 35 |
# File 'lib/tailor/rulers/allow_trailing_line_spaces_ruler.rb', line 27 def measure(lexed_line, lineno, column) if lexed_line.ends_with_sp? actual = lexed_line.last_non_line_feed_event.last.size = "Line has #{actual} trailing spaces." @problems << Problem.new(problem_type, lineno, column, , @options[:level]) end end |
#nl_update(lexed_line, lineno, column) ⇒ Object
18 19 20 |
# File 'lib/tailor/rulers/allow_trailing_line_spaces_ruler.rb', line 18 def nl_update(lexed_line, lineno, column) ignored_nl_update(lexed_line, lineno, column) end |