class Citrus::ButPredicate

A ButPredicate is a Nonterminal that consumes all characters until its rule matches. It must match at least one character in order to succeed. The Citrus notation is any expression preceded by a tilde, e.g.:

~expr

Constants

DOT_RULE

Public Class Methods

new(rule='') click to toggle source
Calls superclass method Citrus::Nonterminal.new
# File lib/citrus.rb, line 1072
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 1082
def exec(input, events=[])
  length = 0

  until input.test(rule)
    len = input.exec(DOT_RULE)[-1]
    break unless len
    length += len
  end

  if length > 0
    events << self
    events << CLOSE
    events << length
  end

  events
end
rule() click to toggle source

Returns the Rule object this rule uses to match.

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