Class: Diakonos::Bookmark

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

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(buffer, row, col, name = nil) ⇒ Bookmark

Returns a new instance of Bookmark.



7
8
9
10
11
12
# File 'lib/diakonos/bookmark.rb', line 7

def initialize( buffer, row, col, name = nil )
  @buffer = buffer
  @row = row
  @col = col
  @name = name
end

Instance Attribute Details

#bufferObject (readonly)

Returns the value of attribute buffer.



5
6
7
# File 'lib/diakonos/bookmark.rb', line 5

def buffer
  @buffer
end

#colObject (readonly)

Returns the value of attribute col.



5
6
7
# File 'lib/diakonos/bookmark.rb', line 5

def col
  @col
end

#nameObject (readonly)

Returns the value of attribute name.



5
6
7
# File 'lib/diakonos/bookmark.rb', line 5

def name
  @name
end

#rowObject (readonly)

Returns the value of attribute row.



5
6
7
# File 'lib/diakonos/bookmark.rb', line 5

def row
  @row
end

Instance Method Details

#<(other) ⇒ Object



28
29
30
# File 'lib/diakonos/bookmark.rb', line 28

def < (other)
  ( ( self <=> other ) < 0 )
end

#<=>(other) ⇒ Object



19
20
21
22
23
24
25
26
# File 'lib/diakonos/bookmark.rb', line 19

def <=> (other)
  return nil if other.nil?
  comparison = ( $diakonos.buffer_to_number( @buffer ) <=> $diakonos.buffer_to_number( other.buffer ) )
  return comparison if comparison != 0
  comparison = ( @row <=> other.row )
  return comparison if comparison != 0
  @col <=> other.col
end

#==(other) ⇒ Object



14
15
16
17
# File 'lib/diakonos/bookmark.rb', line 14

def == (other)
  return false if other.nil?
  ( @buffer == other.buffer && @row == other.row && @col == other.col )
end

#>(other) ⇒ Object



31
32
33
# File 'lib/diakonos/bookmark.rb', line 31

def > (other)
  ( ( self <=> other ) > 0 )
end

#shift(row_inc, col_inc) ⇒ Object



35
36
37
38
# File 'lib/diakonos/bookmark.rb', line 35

def shift( row_inc, col_inc )
  row += row_inc
  col += col_inc
end

#to_sObject



40
41
42
# File 'lib/diakonos/bookmark.rb', line 40

def to_s
  "[#{@name}|#{@buffer.name}:#{@row+1},#{@col+1}]"
end