class KPeg::MatchComposition
Attributes
matches[R]
op[R]
Public Class Methods
new(op, matches)
click to toggle source
# File lib/kpeg/match.rb, line 31 def initialize(op, matches) @op = op @matches = matches end
Public Instance Methods
explain(indent="")
click to toggle source
# File lib/kpeg/match.rb, line 38 def explain(indent="") puts "#{indent}KPeg::Match:#{object_id.to_s(16)}" puts "#{indent} op: #{@op.inspect}" puts "#{indent} matches:" @matches.each do |m| m.explain("#{indent} ") end end
total_string()
click to toggle source
# File lib/kpeg/match.rb, line 47 def total_string @matches.map { |m| m.total_string }.join end
value(obj=nil)
click to toggle source
# File lib/kpeg/match.rb, line 51 def value(obj=nil) values = @matches.map { |m| m.value(obj) } values = @op.prune_values(values) unless @op.action return values.first if values.size == 1 return values end if obj obj.instance_exec(*values, &@op.action) else @op.action.call(*values) end end