Class: BeerRecipe::MashWrapper
- Defined in:
- lib/beer_recipe/mash_wrapper.rb
Instance Method Summary collapse
-
#initialize(record, recipe = nil) ⇒ MashWrapper
constructor
A new instance of MashWrapper.
- #steps ⇒ Object
- #total_mash_time ⇒ Object
Methods inherited from Wrapper
#blank?, #format_method, #method_missing, #respond_to_missing?, set, wrap
Constructor Details
#initialize(record, recipe = nil) ⇒ MashWrapper
Returns a new instance of MashWrapper.
3 4 5 6 |
# File 'lib/beer_recipe/mash_wrapper.rb', line 3 def initialize(record, recipe=nil) @record = record @recipe = recipe end |
Dynamic Method Handling
This class handles dynamic methods through the method_missing method in the class BeerRecipe::Wrapper
Instance Method Details
#steps ⇒ Object
8 9 10 11 12 13 |
# File 'lib/beer_recipe/mash_wrapper.rb', line 8 def steps return [] if @record.nil? @steps ||= @record.mash_steps.map do |step| BeerRecipe::Wrapper.wrap(step, @recipe) end end |
#total_mash_time ⇒ Object
15 16 17 18 |
# File 'lib/beer_recipe/mash_wrapper.rb', line 15 def total_mash_time return 0 if steps.empty? steps.map { |s| s.step_time || 0 }.reduce :+ || 0 end |