Class: Sequence::SingleItem
Overview
represnts a seq over a single item
Constant Summary
Constants inherited
from Sequence
SubSequence, VERSION
Instance Attribute Summary
Attributes inherited from Sequence
#last_match, #maxmatchlen
Instance Method Summary
collapse
Methods included from ArrayLike
#data_class, #index, #like, #new_data, #push, #rindex, #scan, #scan_until, #scanback, #scanback_until, #unshift
Methods inherited from Sequence
#+, #-, #<<, [], #[], #[]=, #_adjust_pos_on_change, #_default_maxmatchlen, #_delete_position, #_normalize_pos, #_parse_slice_args, #all_data, #append, #begin, #check, #check_until, #checkback, #checkback_until, #close, #closed?, #delete, #each, #empty?, #end, #exist?, #existback?, #first, #goto, #holding, #holding!, #holding?, #holding_position, #holding_position!, #holding_position?, #insert, #last, #length, #match?, #matchback?, #modify, #more_data?, #move, #move!, #nearbegin, #nearend, #new, #notify_change, #on_change_notify, #original__new, #overwrite, #pop, #pos=, #pos?, #position, #position=, #position?, #pred, #prepend, #prop, #read!, #readahead, #readback, #readback1, #readbehind, #readbehind1, #rest_size, #reversed, #shift, #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
Returns a new instance of SingleItem.
9
10
11
12
|
# File 'lib/sequence/singleitem.rb', line 9
def initialize(obj)
@obj=obj
@eof=false
end
|
Instance Method Details
#_pos=(pos) ⇒ Object
46
47
48
|
# File 'lib/sequence/singleitem.rb', line 46
def _pos=(pos)
@eof=pos.nonzero?
end
|
#begin! ⇒ Object
34
35
36
|
# File 'lib/sequence/singleitem.rb', line 34
def begin!
@eof=false
end
|
#end! ⇒ Object
38
39
40
|
# File 'lib/sequence/singleitem.rb', line 38
def end!
@eof=true
end
|
#eof? ⇒ Boolean
26
|
# File 'lib/sequence/singleitem.rb', line 26
def eof?; @eof end
|
#pos ⇒ Object
42
43
44
|
# File 'lib/sequence/singleitem.rb', line 42
def pos
@eof ? 1 : 0
end
|
#read(len) ⇒ Object
28
29
30
31
32
|
# File 'lib/sequence/singleitem.rb', line 28
def read(len)
@eof and return []
@eof=true
return [@obj]
end
|
#read1 ⇒ Object
14
15
16
17
18
|
# File 'lib/sequence/singleitem.rb', line 14
def read1
result=readahead1
@eof=true
result
end
|
#readahead1 ⇒ Object
20
21
22
|
# File 'lib/sequence/singleitem.rb', line 20
def readahead1
@obj unless @eof
end
|
#size ⇒ Object
24
|
# File 'lib/sequence/singleitem.rb', line 24
def size; 1 end
|