Class: BeerRecipe::MiscWrapper
Constant Summary
collapse
- DAY =
1440
Instance Method Summary
collapse
Methods inherited from Wrapper
#blank?, #format_method, #initialize, #method_missing, #respond_to_missing?, set, wrap
Dynamic Method Handling
This class handles dynamic methods through the method_missing method
in the class BeerRecipe::Wrapper
Instance Method Details
#days? ⇒ Boolean
8
9
10
|
# File 'lib/beer_recipe/misc_wrapper.rb', line 8
def days?
!blank?(time) && time > DAY
end
|
25
26
27
28
29
30
31
|
# File 'lib/beer_recipe/misc_wrapper.rb', line 25
def formatted_amount
if large_amount?
"#{'%.0f' % amount}"
else
"#{'%.2f' % (1000 * amount)}"
end
end
|
33
34
35
36
37
38
39
40
|
# 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? ⇒ Boolean
12
13
14
|
# File 'lib/beer_recipe/misc_wrapper.rb', line 12
def large_amount?
amount >= 1
end
|
#time_unit ⇒ Object
42
43
44
45
46
47
48
|
# File 'lib/beer_recipe/misc_wrapper.rb', line 42
def time_unit
if days?
'days'
else
'minutes'
end
end
|
#unit ⇒ Object
16
17
18
19
20
21
22
23
|
# File 'lib/beer_recipe/misc_wrapper.rb', line 16
def unit
if weight?
large_amount? ? 'kilograms' : 'grams'
else
large_amount? ? 'items' : 'ml'
end
end
|
#weight? ⇒ Boolean
4
5
6
|
# File 'lib/beer_recipe/misc_wrapper.rb', line 4
def weight?
amount_is_weight
end
|