Class: ParserCombinator::Items
- Inherits:
-
Array
- Object
- Array
- ParserCombinator::Items
- Defined in:
- lib/parser_combinator.rb
Instance Method Summary collapse
- #drop(v) ⇒ Object
- #drop_while(&p) ⇒ Object
- #flatten ⇒ Object
- #head ⇒ Object
- #inspect ⇒ Object
- #rest ⇒ Object
- #slice(pos, len) ⇒ Object
- #take(n) ⇒ Object
- #take_while(&p) ⇒ Object
- #to_s ⇒ Object
- #uniq ⇒ Object
Instance Method Details
#drop(v) ⇒ Object
44 45 46 |
# File 'lib/parser_combinator.rb', line 44 def drop(v) Items.new(super(v)) end |
#drop_while(&p) ⇒ Object
48 49 50 |
# File 'lib/parser_combinator.rb', line 48 def drop_while(&p) Items.new(super(&p)) end |
#flatten ⇒ Object
52 53 54 |
# File 'lib/parser_combinator.rb', line 52 def flatten Items.new(super()) end |
#head ⇒ Object
80 81 82 |
# File 'lib/parser_combinator.rb', line 80 def head self.first end |
#inspect ⇒ Object
92 93 94 |
# File 'lib/parser_combinator.rb', line 92 def inspect "Items [#{self.map(&:inspect).join(",\n")}]" end |
#rest ⇒ Object
84 85 86 |
# File 'lib/parser_combinator.rb', line 84 def rest self.drop(1) end |
#slice(pos, len) ⇒ Object
56 57 58 59 60 61 62 |
# File 'lib/parser_combinator.rb', line 56 def slice(nth) if nth.instance_of? Range then Items.new(super(nth)) else super(nth) end end |
#take(n) ⇒ Object
68 69 70 |
# File 'lib/parser_combinator.rb', line 68 def take(n) Items.new(super(n)) end |
#take_while(&p) ⇒ Object
72 73 74 |
# File 'lib/parser_combinator.rb', line 72 def take_while(&p) Items.new(super(&p)) end |
#to_s ⇒ Object
88 89 90 |
# File 'lib/parser_combinator.rb', line 88 def to_s self.map(&:to_s).join end |