Class: Optimus::ParsedCalculator::PrefixExpr
- Includes:
- Evaluators::Prefix
- Defined in:
- lib/expression_parser/expressions.rb
Direct Known Subclasses
Constant Summary
Constants included from Evaluators::Prefix
Evaluators::Prefix::Neg, Evaluators::Prefix::Not, Evaluators::Prefix::OpTable
Constants inherited from Expr
Instance Attribute Summary collapse
-
#op ⇒ Object
readonly
Returns the value of attribute op.
-
#right ⇒ Object
readonly
Returns the value of attribute right.
Instance Method Summary collapse
- #evaluate(*args) ⇒ Object
-
#initialize(op, right) ⇒ PrefixExpr
constructor
A new instance of PrefixExpr.
- #to_s ⇒ Object
Methods inherited from Expr
#-@, #eq, #logical_and, #logical_not, #logical_or, #neq, #to_bool
Constructor Details
#initialize(op, right) ⇒ PrefixExpr
Returns a new instance of PrefixExpr.
80 81 82 83 |
# File 'lib/expression_parser/expressions.rb', line 80 def initialize(op, right) @op = op @right = right end |
Instance Attribute Details
#op ⇒ Object (readonly)
Returns the value of attribute op.
79 80 81 |
# File 'lib/expression_parser/expressions.rb', line 79 def op @op end |
#right ⇒ Object (readonly)
Returns the value of attribute right.
79 80 81 |
# File 'lib/expression_parser/expressions.rb', line 79 def right @right end |
Instance Method Details
#evaluate(*args) ⇒ Object
89 90 91 92 |
# File 'lib/expression_parser/expressions.rb', line 89 def evaluate(*args) rval = @right.evaluate(*args) return OpTable[@op].call(rval) end |
#to_s ⇒ Object
85 86 87 |
# File 'lib/expression_parser/expressions.rb', line 85 def to_s "#{@op}(#{@right})" end |