Class: Formula
- Inherits:
-
Object
- Object
- Formula
- Defined in:
- lib/hypatia/formula.rb
Instance Attribute Summary collapse
-
#operations ⇒ Object
readonly
Returns the value of attribute operations.
-
#result ⇒ Object
readonly
Returns the value of attribute result.
Instance Method Summary collapse
- #difficulty ⇒ Object
-
#initialize(operations) ⇒ Formula
constructor
A new instance of Formula.
- #text ⇒ Object
Constructor Details
#initialize(operations) ⇒ Formula
4 5 6 |
# File 'lib/hypatia/formula.rb', line 4 def initialize(operations) @operations = operations end |
Instance Attribute Details
#operations ⇒ Object (readonly)
Returns the value of attribute operations.
2 3 4 |
# File 'lib/hypatia/formula.rb', line 2 def operations @operations end |
#result ⇒ Object (readonly)
Returns the value of attribute result.
2 3 4 |
# File 'lib/hypatia/formula.rb', line 2 def result @result end |
Instance Method Details
#difficulty ⇒ Object
16 17 18 19 20 21 22 |
# File 'lib/hypatia/formula.rb', line 16 def difficulty if @operations.length > 0 FormulaDifficultyCalculator.new(self).difficulty else nil end end |
#text ⇒ Object
8 9 10 |
# File 'lib/hypatia/formula.rb', line 8 def text @operations.map(&:text).join(" \n ") end |