Class: BreadCalculator::Step
- Inherits:
-
Object
- Object
- BreadCalculator::Step
- Defined in:
- lib/bread_calculator.rb
Overview
This class represents a discrete step in a Recipe.
Instance Attribute Summary collapse
-
#ingredients ⇒ Object
readonly
Returns the value of attribute ingredients.
-
#techniques ⇒ Object
Returns the value of attribute techniques.
Instance Method Summary collapse
-
#initialize(*args) ⇒ Step
constructor
Creates a new step with the the optional array
techniques
, which consists of ministep strings, andIngredients
. -
#to_html ⇒ Object
Print Step as an html paragraph.
-
#to_s(summary = nil) ⇒ Object
Print a nice text version of Step.
Constructor Details
#initialize(*args) ⇒ Step
Creates a new step with the the optional array techniques
, which consists of ministep strings, and Ingredients
.
This is intended to read something like: "Mix:", @flour, @water, "thoroughly."
or:
"Serve forth."
111 112 113 |
# File 'lib/bread_calculator.rb', line 111 def initialize *args self.techniques = args.flatten end |
Instance Attribute Details
#ingredients ⇒ Object (readonly)
Returns the value of attribute ingredients.
98 99 100 |
# File 'lib/bread_calculator.rb', line 98 def ingredients @ingredients end |
#techniques ⇒ Object
Returns the value of attribute techniques.
98 99 100 |
# File 'lib/bread_calculator.rb', line 98 def techniques @techniques end |
Instance Method Details
#to_html ⇒ Object
Print Step as an html paragraph
139 140 141 142 143 144 145 146 147 |
# File 'lib/bread_calculator.rb', line 139 def to_html out = "<p>\n" self.techniques.each do |t| tmp = t.is_a?(Ingredient) ? t.to_html : "#{CGI.escapeHTML(t.chomp)}" out << tmp end out << "\n</p>\n" out end |
#to_s(summary = nil) ⇒ Object
Print a nice text version of Step
126 127 128 129 130 131 132 133 134 |
# File 'lib/bread_calculator.rb', line 126 def to_s summary=nil out = '' self.techniques.each do |t| tmp = t.is_a?(Ingredient) ? t.to_s(summary) : "#{t.chomp}\n" out << tmp end out << "\n" out end |