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

Attributes inherited from Sequence

#last_match, #maxmatchlen

Instance Method Summary collapse

Methods inherited from UseData

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

Methods inherited from Sequence

#+, #-, #<<, [], #[], #[]=, #_adjust_pos_on_change, #_default_maxmatchlen, #_delete_position, #_normalize_pos, #_parse_slice_args, #all_data, #append, #begin, #begin!, #check, #check_until, #checkback, #checkback_until, #delete, #each, #empty?, #end, #end!, #exist?, #existback?, #first, #goto, #holding, #holding!, #holding?, #holding_position, #holding_position!, #holding_position?, #insert, #last, #length, #match?, #matchback?, #modify, #more_data?, #move, #move!, #new, #notify_change, #on_change_notify, #original__new, #overwrite, #pop, #pos=, #pos?, #position=, #position?, #pred, #prepend, #prop, #read, #read!, #read1, #readahead, #readahead1, #readback, #readback1, #readbehind, #readbehind1, #rest_size, #reversed, #shift, #size, #skip, #skip_literal, #skip_until, #skip_until_literal, #skipback, #skipback_until, #slice, #slice!, #slice1, #slice1!, #subseq, #succ, #to_sequence, #was_data?, #write, #writeahead, #writeback, #writebehind

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