Module: CookingSpoon

Defined in:
lib/cooking_spoon.rb,
lib/cooking_spoon/unit.rb,
lib/cooking_spoon/config.rb,
lib/cooking_spoon/version.rb

Defined Under Namespace

Modules: Unit Classes: Config

Constant Summary collapse

VERSION =
"0.1.2"

Class Method Summary collapse

Class Method Details

.configure(&block) ⇒ Object



17
18
19
# File 'lib/cooking_spoon/config.rb', line 17

def configure(&block)
  block.call(CookingSpoon::Config.instance)
end

.quantity(quantity) ⇒ Object



22
23
24
# File 'lib/cooking_spoon.rb', line 22

def quantity(quantity)
  "#{spoon_format(quantity)}"
end

.quantity_and_unit(quantity, unit = 1) ⇒ Object



7
8
9
10
11
12
13
14
15
16
17
18
19
20
# 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