Class Citrus::AndPredicate

  1. lib/citrus.rb
Parent: Object

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

Methods

public class

  1. new

public instance

  1. exec
  2. rule

Included modules

  1. Nonterminal

Public class methods

new (rule='')
[show source]
      # File lib/citrus.rb, line 1001
1001:     def initialize(rule='')
1002:       super([rule])
1003:     end

Public instance methods

exec (input, events=[])

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

[show source]
      # File lib/citrus.rb, line 1011
1011:     def exec(input, events=[])
1012:       if input.test(rule)
1013:         events << self
1014:         events << CLOSE
1015:         events << 0
1016:       end
1017: 
1018:       events
1019:     end
rule ()

Returns the Rule object this rule uses to match.

[show source]
      # File lib/citrus.rb, line 1006
1006:     def rule
1007:       rules[0]
1008:     end