Class: DParse::Parsers::Any

Inherits:
DParse::Parser show all
Defined in:
lib/d-parse/parsers/primitives/any.rb

Instance Method Summary collapse

Methods inherited from DParse::Parser

#apply, #bind, #capture, #compact, #first, #flatten, #ignore, #map, #match?, #second, #select_even, #select_odd, #to_s

Instance Method Details

#expectation_messageObject



17
18
19
# File 'lib/d-parse/parsers/primitives/any.rb', line 17

def expectation_message
  'any character except end of file'
end

#inspectObject



13
14
15
# File 'lib/d-parse/parsers/primitives/any.rb', line 13

def inspect
  'any()'
end

#read(input, pos) ⇒ Object



4
5
6
7
8
9
10
11
# File 'lib/d-parse/parsers/primitives/any.rb', line 4

def read(input, pos)
  char = input[pos.index]
  if char
    Success.new(input, pos.advance(char))
  else
    Failure.new(input, pos, origin: self)
  end
end