class ParserResult

Attributes

matched[R]
output[R]
remaining[R]
success[R]

Public Class Methods

fail(remaining) click to toggle source
# File lib/parser_result.rb, line 16
def self.fail(remaining)
  ParserResult.new(false, remaining, "")
end
new(success, remaining, matched, output=nil) click to toggle source
# File lib/parser_result.rb, line 3
def initialize(success, remaining, matched, output=nil)
  @success   = success
  @remaining = remaining
  @matched   = matched
  @output = output.nil? ? [matched] : output
end
ok(output=nil, matched:, remaining:) click to toggle source
# File lib/parser_result.rb, line 10
  def self.ok(output=nil, matched:, remaining:)
#    yield matched if block_given?
    output = [matched] if output.nil?
    ParserResult.new(true, remaining, matched, output)
  end

Public Instance Methods

==(other) click to toggle source
# File lib/parser_result.rb, line 28
def ==(other)
  return other.instance_of?(self.class) && other.success == success && other.remaining == remaining && other.matched == matched
end
fail?() click to toggle source
# File lib/parser_result.rb, line 24
def fail?
  success == false
end
ok?() click to toggle source
# File lib/parser_result.rb, line 20
def ok?
  success
end
to_s() click to toggle source
# File lib/parser_result.rb, line 32
def to_s()
  "ParserResult: {\n" +
  "\tSuccess: " + success.to_s + 
  "\n\tRemaining: '" + remaining.to_s + 
  "'\n\tMatched: '" + matched.to_s + 
  "'\n\tOutput: " + output.to_s + "\n}"
end