class Citrus::AndPredicate

An AndPredicate is a Nonterminal that contains a rule that must match. Upon success an empty match is returned and no input is consumed. The Citrus notation is any expression preceded by an ampersand, e.g.:

&expr

Public Class Methods

new(rule='') click to toggle source
Calls superclass method Citrus::Nonterminal.new
# File lib/citrus.rb, line 1000
def initialize(rule='')
  super([rule])
end

Public Instance Methods

exec(input, events=[]) click to toggle source

Returns an array of events for this rule on the given input.

# File lib/citrus.rb, line 1010
def exec(input, events=[])
  if input.test(rule)
    events << self
    events << CLOSE
    events << 0
  end

  events
end
rule() click to toggle source

Returns the Rule object this rule uses to match.

# File lib/citrus.rb, line 1005
def rule
  rules[0]
end