Class: Gobstones::Lang::TwoArgExpression
- Inherits:
-
Expression
- Object
- Expression
- Gobstones::Lang::TwoArgExpression
- Defined in:
- lib/gobstones/lang/expressions/two_arg_expression.rb
Direct Known Subclasses
And, ArithmeticExpression, Equal, GreaterEqual, GreaterThan, LessEqual, LessThan, NotEqual, Or
Instance Attribute Summary collapse
-
#left_expr ⇒ Object
readonly
Returns the value of attribute left_expr.
-
#right_expr ⇒ Object
readonly
Returns the value of attribute right_expr.
Class Method Summary collapse
Instance Method Summary collapse
- #equality_attributes ⇒ Object
-
#initialize(left, right) ⇒ TwoArgExpression
constructor
A new instance of TwoArgExpression.
Methods inherited from Expression
Methods included from EqualityDefinition
Constructor Details
#initialize(left, right) ⇒ TwoArgExpression
Returns a new instance of TwoArgExpression.
21 22 23 24 |
# File 'lib/gobstones/lang/expressions/two_arg_expression.rb', line 21 def initialize(left, right) @left_expr = left @right_expr = right end |
Instance Attribute Details
#left_expr ⇒ Object (readonly)
Returns the value of attribute left_expr.
6 7 8 |
# File 'lib/gobstones/lang/expressions/two_arg_expression.rb', line 6 def left_expr @left_expr end |
#right_expr ⇒ Object (readonly)
Returns the value of attribute right_expr.
6 7 8 |
# File 'lib/gobstones/lang/expressions/two_arg_expression.rb', line 6 def right_expr @right_expr end |
Class Method Details
.evaluates_with(selector) ⇒ Object
8 9 10 11 12 13 14 15 16 17 18 19 |
# File 'lib/gobstones/lang/expressions/two_arg_expression.rb', line 8 def self.evaluates_with(selector) instance_eval do define_method :evaluate do |*args| context = args.first left_expr.evaluate(context).send(selector, right_expr.evaluate(context)) end define_method :to_s do "#{selector} expression" end end end |
Instance Method Details
#equality_attributes ⇒ Object
26 27 28 |
# File 'lib/gobstones/lang/expressions/two_arg_expression.rb', line 26 def equality_attributes %i[left_expr right_expr] end |