Class: FormulaDSL::BinaryExpression
- Inherits:
-
Object
- Object
- FormulaDSL::BinaryExpression
- Defined in:
- lib/formula_dsl/binary_expression.rb
Instance Attribute Summary collapse
-
#left_term ⇒ Object
readonly
Returns the value of attribute left_term.
-
#operator ⇒ Object
readonly
Returns the value of attribute operator.
-
#right_term ⇒ Object
readonly
Returns the value of attribute right_term.
Instance Method Summary collapse
- #==(other) ⇒ Object
- #apply ⇒ Object
-
#initialize(operator, left_term, right_term) ⇒ BinaryExpression
constructor
A new instance of BinaryExpression.
Constructor Details
#initialize(operator, left_term, right_term) ⇒ BinaryExpression
Returns a new instance of BinaryExpression.
7 8 9 10 11 |
# File 'lib/formula_dsl/binary_expression.rb', line 7 def initialize(operator, left_term, right_term) @operator = operator @left_term = left_term @right_term = right_term end |
Instance Attribute Details
#left_term ⇒ Object (readonly)
Returns the value of attribute left_term.
5 6 7 |
# File 'lib/formula_dsl/binary_expression.rb', line 5 def left_term @left_term end |
#operator ⇒ Object (readonly)
Returns the value of attribute operator.
5 6 7 |
# File 'lib/formula_dsl/binary_expression.rb', line 5 def operator @operator end |
#right_term ⇒ Object (readonly)
Returns the value of attribute right_term.
5 6 7 |
# File 'lib/formula_dsl/binary_expression.rb', line 5 def right_term @right_term end |
Instance Method Details
#==(other) ⇒ Object
21 22 23 |
# File 'lib/formula_dsl/binary_expression.rb', line 21 def == (other) @operator == other.operator && @left_term == other.left_term && @right_term == other.right_term end |
#apply ⇒ Object
13 14 15 16 17 18 19 |
# File 'lib/formula_dsl/binary_expression.rb', line 13 def apply @left_term = @left_term.apply if @left_term.respond_to? :apply @right_term = @right_term.apply if @right_term.respond_to? :apply operation = BinaryExpressionFactory.new(@operator) operation.call(@left_term, @right_term) end |