Class: PlatformosCheck::DisabledCheck

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

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(app_file, name) ⇒ DisabledCheck

Returns a new instance of DisabledCheck.



10
11
12
13
14
15
# File 'lib/platformos_check/disabled_check.rb', line 10

def initialize(app_file, name)
  @app_file = app_file
  @name = name
  @ranges = []
  @first_line = false
end

Instance Attribute Details

#app_fileObject (readonly)

Returns the value of attribute app_file.



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

def app_file
  @app_file
end

#first_lineObject

Returns the value of attribute first_line.



8
9
10
# File 'lib/platformos_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/platformos_check/disabled_check.rb', line 7

def name
  @name
end

#rangesObject (readonly)

Returns the value of attribute ranges.



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

def ranges
  @ranges
end

Instance Method Details

#disabled?(index) ⇒ Boolean

Returns:

  • (Boolean)


29
30
31
32
# File 'lib/platformos_check/disabled_check.rb', line 29

def disabled?(index)
  (index == 0 && first_line) ||
    ranges.any? { |range| range.cover?(index) }
end

#end_index=(index) ⇒ Object



23
24
25
26
27
# File 'lib/platformos_check/disabled_check.rb', line 23

def end_index=(index)
  return if ranges.empty? || !last.end.nil?

  @ranges << (@ranges.pop.begin..index)
end

#lastObject



34
35
36
# File 'lib/platformos_check/disabled_check.rb', line 34

def last
  ranges.last
end

#missing_end_index?Boolean

Returns:

  • (Boolean)


38
39
40
41
42
# File 'lib/platformos_check/disabled_check.rb', line 38

def missing_end_index?
  return false if first_line && ranges.size == 1

  last&.end.nil?
end

#start_index=(index) ⇒ Object



17
18
19
20
21
# File 'lib/platformos_check/disabled_check.rb', line 17

def start_index=(index)
  return unless ranges.empty? || !last.end.nil?

  @ranges << (index..)
end