Class: Romanesco::SubtractionOperator

Inherits:
BinaryOperator show all
Defined in:
lib/romanesco/elements/subtraction_operator.rb

Instance Attribute Summary

Attributes inherited from BinaryOperator

#left_operand, #right_operand, #symbol

Attributes inherited from Operator

#symbol

Attributes inherited from Expression

#parent

Instance Method Summary collapse

Methods inherited from BinaryOperator

#insert_element_to_left, #insert_element_to_right, #to_s

Methods inherited from Operator

#check_for_blank_symbol, #connect, #connect_in_place, #connect_in_place_with_parent, #connect_to_left, #connect_to_right, #connect_up_tree, #precedence, #precedence=

Constructor Details

#initialize(symbol) ⇒ SubtractionOperator

Returns a new instance of SubtractionOperator.



4
5
6
# File 'lib/romanesco/elements/subtraction_operator.rb', line 4

def initialize(symbol)
  @symbol = '-'
end

Instance Method Details

#default_precedenceObject



13
14
15
# File 'lib/romanesco/elements/subtraction_operator.rb', line 13

def default_precedence
  10
end

#evaluate(options) ⇒ Object



8
9
10
11
# File 'lib/romanesco/elements/subtraction_operator.rb', line 8

def evaluate(options)
  left_result, right_result = super(options)
  left_result - right_result
end