Class: Sequence::Position

Inherits:
UseData show all
Defined in:
lib/sequence/position.rb

Overview

do it and returns the parent to where it was.

Constant Summary

Constants inherited from Sequence

SubSequence, VERSION

Instance Attribute Summary collapse

Instance Method Summary collapse

Methods inherited from UseData

#read, #readahead, #readback, #readbehind, #size

Constructor Details

#initialize(parent, pos = parent.pos) ⇒ Position

:nodoc:



14
15
16
17
18
19
20
21
# File 'lib/sequence/position.rb', line 14

def initialize(parent,pos=parent.pos)
    Position===parent and raise ArgumentError
    @data = parent
    @pos = _normalize_pos pos
    extend parent.like
    prop(nil,parent.prop)
    @data.on_change_notify self
end

Instance Attribute Details

#dataObject (readonly)

Returns the value of attribute data.



63
64
65
# File 'lib/sequence/position.rb', line 63

def data
  @data
end

#posObject (readonly)

Returns the value of attribute pos.



63
64
65
# File 'lib/sequence/position.rb', line 63

def pos
  @pos
end

Instance Method Details

#_pos=(p) ⇒ Object



34
35
36
# File 'lib/sequence/position.rb', line 34

def _pos=(p)
        @pos = p
end

#change_notification(data, first, oldsize, newsize) ⇒ Object



23
24
25
26
27
28
# File 'lib/sequence/position.rb', line 23

def change_notification data,first,oldsize,newsize
  assert @data==data 
  @pos=_adjust_pos_on_change @pos,first,oldsize,newsize
  
  notify_change self,first,oldsize,newsize 
end

#closeObject



70
71
72
73
# File 'lib/sequence/position.rb', line 70

def close
    @data._delete_position(self)
    super
end

#closed?Boolean

Returns:

  • (Boolean)


66
67
68
# File 'lib/sequence/position.rb', line 66

def closed?
  super or @data.closed?
end

#eof?Boolean

Returns:

  • (Boolean)


61
# File 'lib/sequence/position.rb', line 61

def eof?; @pos>=size end

#nearbegin(len, at = pos) ⇒ Object



51
52
53
# File 'lib/sequence/position.rb', line 51

def nearbegin(len,at=pos)
  @data.nearbegin(len,at)
end

#nearend(len, at = pos) ⇒ Object



55
56
57
# File 'lib/sequence/position.rb', line 55

def nearend(len,at=pos)
  @data.nearend(len,at)
end

#position(pos = @pos) ⇒ Object Also known as: dup



37
38
39
# File 'lib/sequence/position.rb', line 37

def position(pos=@pos)
  @data.position(pos)
end