Class: Farseer::Char

Inherits:
Object
  • Object
show all
Includes:
MapFactory
Defined in:
lib/farseer/char.rb

Constant Summary collapse

L_PARENS =
new('(')
R_PARENS =
new(')')
PLUS =
new('+')
MINUS =
new('-')
STAR =
new('*')
SLASH =
new('/')

Instance Method Summary collapse

Methods included from MapFactory

#map

Constructor Details

#initialize(char) ⇒ Char

Returns a new instance of Char.



7
8
9
10
# File 'lib/farseer/char.rb', line 7

def initialize(char)
  @char = char
  freeze
end

Instance Method Details

#parse(input) ⇒ Object



19
20
21
22
23
24
# File 'lib/farseer/char.rb', line 19

def parse(input)
  case input[0]
  when @char then Maybe.return(Result.new(input[0], input[1..]))
  else Maybe.none
  end
end