Class: Farseer::Word

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

Instance Method Summary collapse

Methods included from MapFactory

#map

Constructor Details

#initialize(word) ⇒ Word

Returns a new instance of Word.



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

def initialize(word)
  @word = word
  freeze
end

Instance Method Details

#parse(input) ⇒ Object



12
13
14
15
16
17
# File 'lib/farseer/word.rb', line 12

def parse(input)
  case
  when input.start_with?(@word) then Maybe.return(Result.new(@word, input[@word.length..]))
  else Maybe.none
  end
end