Class: Tailor::Rulers::AllowHardTabsRuler

Inherits:
Tailor::Ruler show all
Defined in:
lib/tailor/rulers/allow_hard_tabs_ruler.rb

Instance Attribute Summary

Attributes inherited from Tailor::Ruler

#lexer_observers

Instance Method Summary collapse

Methods inherited from Tailor::Ruler

#add_child_ruler, #problem_type, #problems

Methods included from Logger::Mixin

included

Constructor Details

#initialize(config, options) ⇒ AllowHardTabsRuler

Returns a new instance of AllowHardTabsRuler.



6
7
8
9
# File 'lib/tailor/rulers/allow_hard_tabs_ruler.rb', line 6

def initialize(config, options)
  super(config, options)
  add_lexer_observers :sp
end

Instance Method Details

#measure(token, lineno, column) ⇒ Object

Checks to see if the space(s) contains hard tabs.

Parameters:

  • token (Fixnum)

    The space(s).

  • lineno (Fixnum)

    Line the problem was found on.

  • column (Fixnum)

    Column the problem was found on.



20
21
22
23
24
25
26
27
# File 'lib/tailor/rulers/allow_hard_tabs_ruler.rb', line 20

def measure(token, lineno, column)
  if token.contains_hard_tab?
    problem_message = 'Hard tab found.'

    @problems << Problem.new(problem_type, lineno, column,
      problem_message, @options[:level])
  end
end

#sp_update(token, lineno, column) ⇒ Object



11
12
13
# File 'lib/tailor/rulers/allow_hard_tabs_ruler.rb', line 11

def sp_update(token, lineno, column)
  measure(token, lineno, column)
end