Class: Arithmetic::Operator
- Inherits:
-
Object
- Object
- Arithmetic::Operator
- Defined in:
- lib/arithmetic/operators.rb
Instance Attribute Summary collapse
-
#priority ⇒ Object
readonly
Returns the value of attribute priority.
-
#string ⇒ Object
readonly
Returns the value of attribute string.
Instance Method Summary collapse
- #arity ⇒ Object
- #eval(*args) ⇒ Object
-
#initialize(string, priority, function) ⇒ Operator
constructor
A new instance of Operator.
- #to_s ⇒ Object
Constructor Details
#initialize(string, priority, function) ⇒ Operator
Returns a new instance of Operator.
5 6 7 8 9 |
# File 'lib/arithmetic/operators.rb', line 5 def initialize(string, priority, function) @string = string @priority = priority @function = function end |
Instance Attribute Details
#priority ⇒ Object (readonly)
Returns the value of attribute priority.
3 4 5 |
# File 'lib/arithmetic/operators.rb', line 3 def priority @priority end |
#string ⇒ Object (readonly)
Returns the value of attribute string.
3 4 5 |
# File 'lib/arithmetic/operators.rb', line 3 def string @string end |
Instance Method Details
#arity ⇒ Object
19 20 21 |
# File 'lib/arithmetic/operators.rb', line 19 def arity @function.arity end |
#eval(*args) ⇒ Object
11 12 13 |
# File 'lib/arithmetic/operators.rb', line 11 def eval(*args) @function.call(*args) end |
#to_s ⇒ Object
15 16 17 |
# File 'lib/arithmetic/operators.rb', line 15 def to_s @string end |