Class: TheFox::Range::Lexer::Collection
- Inherits:
-
Object
- Object
- TheFox::Range::Lexer::Collection
- Defined in:
- lib/thefox-ext/range/lexer/collection.rb
Instance Method Summary collapse
- #curr ⇒ Object
-
#initialize(items = nil) ⇒ Collection
constructor
A new instance of Collection.
-
#inspect ⇒ Object
:nocov:.
- #is_empty ⇒ Object
-
#items ⇒ Object
:nocov:.
- #length ⇒ Object
- #pop ⇒ Object
- #prev ⇒ Object
- #push(item) ⇒ Object
Constructor Details
#initialize(items = nil) ⇒ Collection
Returns a new instance of Collection.
6 7 8 9 10 |
# File 'lib/thefox-ext/range/lexer/collection.rb', line 6 def initialize(items = nil) # puts '-> Collection.initialize()' @items = items.to_a @block_level = 0 end |
Instance Method Details
#curr ⇒ Object
25 26 27 |
# File 'lib/thefox-ext/range/lexer/collection.rb', line 25 def curr() @items.last end |
#inspect ⇒ Object
:nocov:
13 14 15 16 17 18 |
# File 'lib/thefox-ext/range/lexer/collection.rb', line 13 def inspect() 'Collection(L=%d %s)' % [ @items.length, @items.map{ |i| i.inspect } ] end |
#is_empty ⇒ Object
33 34 35 |
# File 'lib/thefox-ext/range/lexer/collection.rb', line 33 def is_empty() @items.length == 0 end |
#items ⇒ Object
:nocov:
21 22 23 |
# File 'lib/thefox-ext/range/lexer/collection.rb', line 21 def items() @items end |
#length ⇒ Object
37 38 39 |
# File 'lib/thefox-ext/range/lexer/collection.rb', line 37 def length() @items.length end |
#pop ⇒ Object
67 68 69 |
# File 'lib/thefox-ext/range/lexer/collection.rb', line 67 def pop() @items.pop end |
#prev ⇒ Object
29 30 31 |
# File 'lib/thefox-ext/range/lexer/collection.rb', line 29 def prev() @items[-2] end |
#push(item) ⇒ Object
41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 |
# File 'lib/thefox-ext/range/lexer/collection.rb', line 41 def push(item) # puts '-> %s.push(%s)' % [self.inspect, item.inspect] if item.nil? return end # Prev org_prev_item = item.prev_item prev_item = @items.last # Dup curr_item = item.dup @items.push(curr_item) # Chain curr_item.chain(prev_item) curr_item.org_prev_item = org_prev_item if curr_item.class.keep_nonce_on_dup curr_item.nonce = item.nonce end if curr_item.class.keep_instance_id_on_dup curr_item.instance_id = item.instance_id end end |