class DParse::Parsers::CharNotIn
Public Class Methods
new(chars)
click to toggle source
# File lib/d-parse/parsers/primitives/char_not_in.rb, line 4 def initialize(chars) unless chars.all? { |char| char.length == 1 } raise ArgumentError, 'Expected input to have one char' end @chars = chars end
Public Instance Methods
expectation_message()
click to toggle source
# File lib/d-parse/parsers/primitives/char_not_in.rb, line 25 def expectation_message "any character not in #{@chars.map { |c| display(c) }.join(', ')}" end
inspect()
click to toggle source
# File lib/d-parse/parsers/primitives/char_not_in.rb, line 21 def inspect "char_not_in(#{@chars.inspect})" end
read(input, pos)
click to toggle source
# File lib/d-parse/parsers/primitives/char_not_in.rb, line 12 def read(input, pos) char = input[pos.index] if char && @chars.all? { |c| char != c } Success.new(input, pos.advance(char)) else Failure.new(input, pos, origin: self) end end