Class: Sequence::OfArray
- Includes:
- ArrayLike
- Defined in:
- lib/sequence/indexed.rb
Direct Known Subclasses
Constant Summary
Constants inherited from Sequence
Instance Attribute Summary
Attributes inherited from Indexed
Instance Method Summary collapse
- #append(arr) ⇒ Object
-
#index(pat, offset = 0) ⇒ Object
a better, string-like #index…
- #new_data ⇒ Object
-
#rindex(pat, offset = size) ⇒ Object
a better, string-like #rindex…
Methods included from ArrayLike
#data_class, #like, #push, #scan, #scan_until, #scanback, #scanback_until, #unshift
Methods inherited from Indexed
_orig_new, #_pos=, #eof?, #initialize, #maxmatchlen, #maxmatchlen=, #modify
Methods inherited from UseData
#read, #readahead, #readback, #readbehind, #size
Constructor Details
This class inherits a constructor from Sequence::Indexed
Instance Method Details
#append(arr) ⇒ Object
102 103 104 105 106 107 |
# File 'lib/sequence/indexed.rb', line 102 def append(arr) sz=size @data.push(*arr) notify_change(self,sz,0,arr.size) self end |
#index(pat, offset = 0) ⇒ Object
a better, string-like #index… with an offset parameter scalar matchers only
87 88 89 90 91 92 |
# File 'lib/sequence/indexed.rb', line 87 def index(pat,offset=0) pat=pat.dup class<<pat; alias == ===; end offset.zero? and return( @data.index pat) @data[offset..-1].index(pat)+offset end |
#new_data ⇒ Object
109 110 111 |
# File 'lib/sequence/indexed.rb', line 109 def new_data [] end |
#rindex(pat, offset = size) ⇒ Object
a better, string-like #rindex… with an offset parameter scalar matchers only
96 97 98 99 100 |
# File 'lib/sequence/indexed.rb', line 96 def rindex(pat,offset=size) pat=pat.dup class<<pat; alias == ===; end (offset==size ? @data : @data[0...offset]).rindex pat end |