Class: Diakonos::TextMark

Inherits:
Object show all
Defined in:
lib/diakonos/text-mark.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(start_row, start_col, end_row, end_col, formatting) ⇒ TextMark

Returns a new instance of TextMark



6
7
8
9
10
11
12
# File 'lib/diakonos/text-mark.rb', line 6

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

Instance Attribute Details

#end_colObject (readonly)

Returns the value of attribute end_col



4
5
6
# File 'lib/diakonos/text-mark.rb', line 4

def end_col
  @end_col
end

#end_rowObject (readonly)

Returns the value of attribute end_row



4
5
6
# File 'lib/diakonos/text-mark.rb', line 4

def end_row
  @end_row
end

#formattingObject (readonly)

Returns the value of attribute formatting



4
5
6
# File 'lib/diakonos/text-mark.rb', line 4

def formatting
  @formatting
end

#start_colObject (readonly)

Returns the value of attribute start_col



4
5
6
# File 'lib/diakonos/text-mark.rb', line 4

def start_col
  @start_col
end

#start_rowObject (readonly)

Returns the value of attribute start_row



4
5
6
# File 'lib/diakonos/text-mark.rb', line 4

def start_row
  @start_row
end

Instance Method Details

#contains?(row, col) ⇒ Boolean

Returns:

  • (Boolean)


18
19
20
21
22
23
24
25
26
# File 'lib/diakonos/text-mark.rb', line 18

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

#to_sObject



14
15
16
# File 'lib/diakonos/text-mark.rb', line 14

def to_s
  "(#{start_row},#{start_col})-(#{end_row},#{end_col}) #{formatting}"
end