Class: ThemeCheck::DisabledCheck
- Inherits:
-
Object
- Object
- ThemeCheck::DisabledCheck
- Defined in:
- lib/theme_check/disabled_check.rb
Instance Attribute Summary collapse
-
#first_line ⇒ Object
Returns the value of attribute first_line.
-
#name ⇒ Object
readonly
Returns the value of attribute name.
-
#ranges ⇒ Object
readonly
Returns the value of attribute ranges.
-
#template ⇒ Object
readonly
Returns the value of attribute template.
Instance Method Summary collapse
- #disabled?(index) ⇒ Boolean
- #end_index=(index) ⇒ Object
-
#initialize(template, name) ⇒ DisabledCheck
constructor
A new instance of DisabledCheck.
- #last ⇒ Object
- #missing_end_index? ⇒ Boolean
- #start_index=(index) ⇒ Object
Constructor Details
#initialize(template, name) ⇒ DisabledCheck
Returns a new instance of DisabledCheck.
10 11 12 13 14 15 |
# File 'lib/theme_check/disabled_check.rb', line 10 def initialize(template, name) @template = template @name = name @ranges = [] @first_line = false end |
Instance Attribute Details
#first_line ⇒ Object
Returns the value of attribute first_line.
8 9 10 |
# File 'lib/theme_check/disabled_check.rb', line 8 def first_line @first_line end |
#name ⇒ Object (readonly)
Returns the value of attribute name.
7 8 9 |
# File 'lib/theme_check/disabled_check.rb', line 7 def name @name end |
#ranges ⇒ Object (readonly)
Returns the value of attribute ranges.
7 8 9 |
# File 'lib/theme_check/disabled_check.rb', line 7 def ranges @ranges end |
#template ⇒ Object (readonly)
Returns the value of attribute template.
7 8 9 |
# File 'lib/theme_check/disabled_check.rb', line 7 def template @template end |
Instance Method Details
#disabled?(index) ⇒ Boolean
27 28 29 30 |
# File 'lib/theme_check/disabled_check.rb', line 27 def disabled?(index) index == 0 && first_line || ranges.any? { |range| range.cover?(index) } end |
#end_index=(index) ⇒ Object
22 23 24 25 |
# File 'lib/theme_check/disabled_check.rb', line 22 def end_index=(index) return if ranges.empty? || !last.end.nil? @ranges << (@ranges.pop.begin..index) end |
#last ⇒ Object
32 33 34 |
# File 'lib/theme_check/disabled_check.rb', line 32 def last ranges.last end |
#missing_end_index? ⇒ Boolean
36 37 38 39 |
# File 'lib/theme_check/disabled_check.rb', line 36 def missing_end_index? return false if first_line && ranges.size == 1 last&.end.nil? end |
#start_index=(index) ⇒ Object
17 18 19 20 |
# File 'lib/theme_check/disabled_check.rb', line 17 def start_index=(index) return unless ranges.empty? || !last.end.nil? @ranges << (index..) end |