Class: Diakonos::Range

Inherits:
Object show all
Defined in:
lib/diakonos/range.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(start_row, start_col, end_row, end_col) ⇒ Range

Returns a new instance of Range.



6
7
8
# File 'lib/diakonos/range.rb', line 6

def initialize( start_row, start_col, end_row, end_col )
  @start_row, @start_col, @end_row, @end_col = start_row, start_col, end_row, end_col
end

Instance Attribute Details

#end_colObject

Returns the value of attribute end_col.



3
4
5
# File 'lib/diakonos/range.rb', line 3

def end_col
  @end_col
end

#end_rowObject

Returns the value of attribute end_row.



3
4
5
# File 'lib/diakonos/range.rb', line 3

def end_row
  @end_row
end

#start_colObject (readonly)

Returns the value of attribute start_col.



3
4
5
# File 'lib/diakonos/range.rb', line 3

def start_col
  @start_col
end

#start_rowObject (readonly)

Returns the value of attribute start_row.



3
4
5
# File 'lib/diakonos/range.rb', line 3

def start_row
  @start_row
end

Instance Method Details

#contains?(row, col) ⇒ Boolean

Returns:

  • (Boolean)


10
11
12
13
14
15
16
17
18
# File 'lib/diakonos/range.rb', line 10

def contains?(row, col)
  if row == @start_row
    @start_col <= col
  elsif row == @end_row
    col < @end_col
  else
    @start_row < row && row < @end_row
  end
end