class BeerRecipe::MiscWrapper

Constants

DAY

Public Instance Methods

days?() click to toggle source
# File lib/beer_recipe/misc_wrapper.rb, line 8
def days?
  !blank?(time) && time > DAY
end
formatted_amount() click to toggle source
# File lib/beer_recipe/misc_wrapper.rb, line 25
def formatted_amount
  if large_amount?
    "#{'%.0f' % amount}"
  else
    "#{'%.2f' % (1000 * amount)}"
  end
end
formatted_time() click to toggle source
# File lib/beer_recipe/misc_wrapper.rb, line 33
def formatted_time
  return "" if blank?(time)
  if days?
    "#{'%.0f' % (time / DAY)}"
  else
    "#{'%.0f' % time}"
  end
end
large_amount?() click to toggle source
# File lib/beer_recipe/misc_wrapper.rb, line 12
def large_amount?
  amount >= 1
end
time_unit() click to toggle source
# File lib/beer_recipe/misc_wrapper.rb, line 42
def time_unit
  if days?
    'days'
  else
    'minutes'
  end
end
unit() click to toggle source
# File lib/beer_recipe/misc_wrapper.rb, line 16
def unit
  # maybe use display_amount directly instead
  if weight?
    large_amount? ? 'kilograms' : 'grams'
  else
    large_amount? ? 'items' : 'ml'
  end
end
weight?() click to toggle source
# File lib/beer_recipe/misc_wrapper.rb, line 4
def weight?
  amount_is_weight
end