class DParse::Parsers::CharNot

Public Class Methods

new(char) click to toggle source
# File lib/d-parse/parsers/primitives/char_not.rb, line 4
def initialize(char)
  raise ArgumentError, 'Expected input to have one char' unless char.length == 1
  @char = char
end

Public Instance Methods

expectation_message() click to toggle source
# File lib/d-parse/parsers/primitives/char_not.rb, line 22
def expectation_message
  "any character not equal to #{display(@char)}"
end
inspect() click to toggle source
# File lib/d-parse/parsers/primitives/char_not.rb, line 18
def inspect
  "char_not(#{@char.inspect})"
end
read(input, pos) click to toggle source
# File lib/d-parse/parsers/primitives/char_not.rb, line 9
def read(input, pos)
  char = input[pos.index]
  if char != @char && char
    Success.new(input, pos.advance(char))
  else
    Failure.new(input, pos, origin: self)
  end
end