class DParse::Parsers::Char
Public Class Methods
new(char)
click to toggle source
# File lib/d-parse/parsers/primitives/char.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.rb, line 22 def expectation_message display(@char) end
inspect()
click to toggle source
# File lib/d-parse/parsers/primitives/char.rb, line 18 def inspect "char(#{@char.inspect})" end
read(input, pos)
click to toggle source
# File lib/d-parse/parsers/primitives/char.rb, line 9 def read(input, pos) char = input[pos.index] if char == @char Success.new(input, pos.advance(char)) else Failure.new(input, pos, origin: self) end end