Class: ThemeCheck::DisabledCheck

Inherits:
Object
  • Object
show all
Defined in:
lib/theme_check/disabled_check.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

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_lineObject

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

#nameObject (readonly)

Returns the value of attribute name.



7
8
9
# File 'lib/theme_check/disabled_check.rb', line 7

def name
  @name
end

#rangesObject (readonly)

Returns the value of attribute ranges.



7
8
9
# File 'lib/theme_check/disabled_check.rb', line 7

def ranges
  @ranges
end

#templateObject (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

Returns:

  • (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

#lastObject



32
33
34
# File 'lib/theme_check/disabled_check.rb', line 32

def last
  ranges.last
end

#missing_end_index?Boolean

Returns:

  • (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