Class: Unicafe::PriceParser

Inherits:
Object
  • Object
show all
Defined in:
lib/unicafe/price_parser.rb

Defined Under Namespace

Classes: PriceError

Constant Summary collapse

MAUKKAASTI =
'4.20'
EDULLISESTI =
'2.60'
KEVYESTI =
'2.30'

Instance Method Summary collapse

Instance Method Details

#parse(price_string) ⇒ Object



10
11
12
13
14
15
16
17
18
19
20
21
22
23
# File 'lib/unicafe/price_parser.rb', line 10

def parse price_string
  case price_string
  when 'Maukkaasti'
    MAUKKAASTI
  when 'Edullisesti'
    EDULLISESTI
  when 'Kevyesti'
    KEVYESTI
  when /^Makeasti (.*)$/
    price_string.match(/([,0-9]+)/)[0].gsub(',','.')
  else
    raise PriceError
  end
end