Class: Nelson::SubtractionExpression
- Inherits:
-
Expression
- Object
- Expression
- Nelson::SubtractionExpression
- Defined in:
- lib/nelson/expressions/subtraction_expression.rb
Instance Attribute Summary
Attributes inherited from Expression
Instance Method Summary collapse
Methods inherited from Expression
#*, #+, #-, #/, #has_term?, #initialize
Constructor Details
This class inherits a constructor from Nelson::Expression
Instance Method Details
#call ⇒ Object
4 5 6 |
# File 'lib/nelson/expressions/subtraction_expression.rb', line 4 def call terms.reduce(:-) end |
#to_s ⇒ Object
9 10 11 12 13 |
# File 'lib/nelson/expressions/subtraction_expression.rb', line 9 def to_s terms.map do |t| t.is_a?(Expression) ? "(#{t})" : t end.join("-") end |