Class: Operation
- Inherits:
-
Object
- Object
- Operation
- Defined in:
- lib/hypatia/formula.rb
Instance Attribute Summary collapse
-
#constant1 ⇒ Object
readonly
Returns the value of attribute constant1.
-
#constant2 ⇒ Object
readonly
Returns the value of attribute constant2.
-
#operator ⇒ Object
readonly
Returns the value of attribute operator.
Instance Method Summary collapse
-
#initialize(operator, constant1, constant2) ⇒ Operation
constructor
A new instance of Operation.
- #result ⇒ Object
- #text ⇒ Object
Constructor Details
#initialize(operator, constant1, constant2) ⇒ Operation
Returns a new instance of Operation.
41 42 43 44 45 |
# File 'lib/hypatia/formula.rb', line 41 def initialize(operator, constant1, constant2) @operator = operator @constant1 = constant1 @constant2 = constant2 end |
Instance Attribute Details
#constant1 ⇒ Object (readonly)
Returns the value of attribute constant1.
40 41 42 |
# File 'lib/hypatia/formula.rb', line 40 def constant1 @constant1 end |
#constant2 ⇒ Object (readonly)
Returns the value of attribute constant2.
40 41 42 |
# File 'lib/hypatia/formula.rb', line 40 def constant2 @constant2 end |
#operator ⇒ Object (readonly)
Returns the value of attribute operator.
40 41 42 |
# File 'lib/hypatia/formula.rb', line 40 def operator @operator end |
Instance Method Details
#result ⇒ Object
51 52 53 |
# File 'lib/hypatia/formula.rb', line 51 def result @constant1.value.send(@operator, @constant2.value) end |
#text ⇒ Object
47 48 49 |
# File 'lib/hypatia/formula.rb', line 47 def text "#{@constant1.value} #{@operator} #{@constant2.value}" end |