module CookingSpoon
Constants
- VERSION
Public Class Methods
configure(&block)
click to toggle source
# File lib/cooking_spoon/config.rb, line 17 def configure(&block) block.call(CookingSpoon::Config.instance) end
quantity(quantity)
click to toggle source
# File lib/cooking_spoon.rb, line 22 def quantity(quantity) "#{spoon_format(quantity)}" end
quantity_and_unit(quantity, unit=1)
click to toggle source
# File lib/cooking_spoon.rb, line 7 def quantity_and_unit(quantity, unit=1) CookingSpoon::Unit::check_unit(unit) case unit when 0, :gram "#{quantity.floor}グラム" when 1, :small_spoon "小さじ#{spoon_format(quantity)}" when 2, :big_spoon "大さじ#{spoon_format(quantity)}" when 3, :a_little "少々" end end
Private Class Methods
spoon_format(quantity)
click to toggle source
# File lib/cooking_spoon.rb, line 28 def spoon_format(quantity) quantity = Rational(quantity) if quantity - quantity.floor > 0 if quantity < 1 "#{Rational(quantity)}" else "#{(quantity.floor)}と#{Rational(quantity - quantity.floor)}" end else "#{quantity.floor}" end end