Class: ParserCombinator::Items

Inherits:
Array
  • Object
show all
Defined in:
lib/parser_combinator.rb

Instance Method Summary collapse

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

#flattenObject



52
53
54
# File 'lib/parser_combinator.rb', line 52

def flatten
  Items.new(super())
end

#headObject



80
81
82
# File 'lib/parser_combinator.rb', line 80

def head
  self.first
end

#inspectObject



92
93
94
# File 'lib/parser_combinator.rb', line 92

def inspect
  "Items [#{self.map(&:inspect).join(",\n")}]"
end

#restObject



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_sObject



88
89
90
# File 'lib/parser_combinator.rb', line 88

def to_s
  self.map(&:to_s).join
end

#uniqObject



76
77
78
# File 'lib/parser_combinator.rb', line 76

def uniq
   Items.new(super())
end