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.



575
576
577
578
# File 'lib/kpeg/grammar.rb', line 575

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

Instance Attribute Details

#opObject (readonly)

Returns the value of attribute op.



580
581
582
# File 'lib/kpeg/grammar.rb', line 580

def op
  @op
end

Instance Method Details

#==(obj) ⇒ Object



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

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

#inspectObject



598
599
600
# File 'lib/kpeg/grammar.rb', line 598

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

#match(x) ⇒ Object



582
583
584
585
586
587
# File 'lib/kpeg/grammar.rb', line 582

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