Method: Sequence#slice
- Defined in:
- lib/sequence.rb
#slice(*args) ⇒ Object
Provides random access for the sequence like what is in Array/String. index can be nil (start at the current location) or a numeric (for #pos=) or a range. len can be nil (get a single element) or the number of elements to #read (positive or negative). The sequence’s position is left alone.
590 591 592 593 594 595 596 597 |
# File 'lib/sequence.rb', line 590 def slice(*args) #index|range=nil,len=nil first,len,only1=_parse_slice_args( *args) pos==first and first=nil holding { self.pos = first if first only1 ? read1 : read(len) } end |