Class: KPeg::Collect

Inherits:
Operator show all
Defined in:
lib/kpeg/grammar.rb

Instance Attribute Summary collapse

Attributes inherited from Operator

#action

Instance Method Summary collapse

Methods inherited from Operator

#detect_tags, #inspect_type, #prune_values, #set_action, #|

Constructor Details

#initialize(op) ⇒ Collect

Returns a new instance of Collect.



585
586
587
588
# File 'lib/kpeg/grammar.rb', line 585

def initialize(op)
  super()
  @op = op
end

Instance Attribute Details

#opObject (readonly)

Returns the value of attribute op.



590
591
592
# File 'lib/kpeg/grammar.rb', line 590

def op
  @op
end

Instance Method Details

#==(obj) ⇒ Object



599
600
601
602
603
604
605
606
# File 'lib/kpeg/grammar.rb', line 599

def ==(obj)
  case obj
  when Collect
    @op == obj.op
  else
    super
  end
end

#inspectObject



608
609
610
# File 'lib/kpeg/grammar.rb', line 608

def inspect
  inspect_type "collect", @op.inspect
end

#match(x) ⇒ Object



592
593
594
595
596
597
# File 'lib/kpeg/grammar.rb', line 592

def match(x)
  start = x.pos
  if @op.match(x)
    MatchString.new(self, x.string[start..x.pos])
  end
end