Method: Eg::Book::Money.parse
- Defined in:
- lib/eg/book/calculate_discount_money.rb
.parse(string) ⇒ Object
28 29 30 31 32 33 34 |
# File 'lib/eg/book/calculate_discount_money.rb', line 28 def Money.parse string raise Exception.new('Invalid money value') unless string =~ /^\$/ dot = string.index '.' raise Exception.new('Invalid money value') if dot.nil? or dot != string.size - 3 money = string[1..-1].to_f Money.new money end |