Class: Minitest::Subjective::FileResult::Range

Inherits:
Struct
  • Object
show all
Defined in:
lib/minitest/subjective/file_result/range.rb

Instance Attribute Summary collapse

Class Method Summary collapse

Instance Method Summary collapse

Instance Attribute Details

#endObject

Returns the value of attribute end

Returns:

  • (Object)

    the current value of end



8
9
10
# File 'lib/minitest/subjective/file_result/range.rb', line 8

def end
  @end
end

#startObject

Returns the value of attribute start

Returns:

  • (Object)

    the current value of start



8
9
10
# File 'lib/minitest/subjective/file_result/range.rb', line 8

def start
  @start
end

Class Method Details

.from_array(args) ⇒ Object



9
10
11
# File 'lib/minitest/subjective/file_result/range.rb', line 9

def self.from_array(args)
  new(start: Location.from_array(args[0..1]), end: Location.from_array(args[2..3]))
end

Instance Method Details

#cover?(line_or_range, column_or_start_column = nil, end_column = nil) ⇒ Boolean

Returns:

  • (Boolean)


21
22
23
24
# File 'lib/minitest/subjective/file_result/range.rb', line 21

def cover?(line_or_range, column_or_start_column = nil, end_column = nil)
  (covers_line?(line_or_range) && !column_or_start_column) || covers_column?(line_or_range,
                                                                             column_or_start_column, end_column)
end

#ends_at?(line, column = nil) ⇒ Boolean

Returns:

  • (Boolean)


17
18
19
# File 'lib/minitest/subjective/file_result/range.rb', line 17

def ends_at?(line, column = nil)
  column ? self.end == Location.new(line, column) : self.end.line == line
end

#starts_at?(line, column = nil) ⇒ Boolean

Returns:

  • (Boolean)


13
14
15
# File 'lib/minitest/subjective/file_result/range.rb', line 13

def starts_at?(line, column = nil)
  column ? start == Location.new(line, column) : start.line == line
end

#to_sObject



26
27
28
29
30
31
32
# File 'lib/minitest/subjective/file_result/range.rb', line 26

def to_s
  if single_line?
    [start.line, [start.column, self.end.column].join('-')].join(':')
  else
    [start.to_s, self.end.to_s].join('-')
  end
end