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



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

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

#<=>(other) ⇒ Object



20
21
22
23
24
25
26
27
28
29
30
# File 'lib/diakonos/bookmark.rb', line 20

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
18
# 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



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

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

#to_sObject



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

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