Class: Keisan::AST::UnaryPlus

Inherits:
UnaryIdentity show all
Defined in:
lib/keisan/ast/unary_plus.rb

Constant Summary

Constants inherited from Operator

Operator::ARITIES, Operator::ARITY_PRIORITY_ASSOCIATIVITY, Operator::ASSOCIATIVITIES, Operator::ASSOCIATIVITY_OF_PRIORITY, Operator::PRIORITIES

Instance Attribute Summary

Attributes inherited from Parent

#children

Class Method Summary collapse

Instance Method Summary collapse

Methods inherited from UnaryIdentity

#differentiate, #evaluate

Methods inherited from UnaryOperator

arity, associativity, #child, #initialize, priority, #to_s

Methods inherited from Operator

#arity, arity, #associativity, associativity, associativity_of_priority, #blank_value, #evaluate_assignments, #initialize, priority, #priority, #symbol, #to_s

Methods inherited from Parent

#==, #deep_dup, #evaluate, #freeze, #initialize, #replace, #unbound_functions, #unbound_variables

Methods inherited from Node

#!, #%, #&, #*, #**, #+, #+@, #-, #-@, #/, #<, #<=, #>, #>=, #^, #and, #coerce, #deep_dup, #differentiate, #equal, #evaluate, #evaluate_assignments, #evaluated, #false?, #not_equal, #or, #replace, #simplified, #to_cell, #to_node, #true?, #unbound_functions, #unbound_variables, #well_defined?, #|, #~

Constructor Details

This class inherits a constructor from Keisan::AST::UnaryOperator

Class Method Details

.symbolObject



8
9
10
# File 'lib/keisan/ast/unary_plus.rb', line 8

def self.symbol
  :"+"
end

Instance Method Details

#simplify(context = nil) ⇒ Object



12
13
14
15
16
17
18
19
# File 'lib/keisan/ast/unary_plus.rb', line 12

def simplify(context = nil)
  case child
  when Number
    Number.new(child.value(context)).simplify(context)
  else
    super
  end
end

#value(context = nil) ⇒ Object



4
5
6
# File 'lib/keisan/ast/unary_plus.rb', line 4

def value(context = nil)
  return children.first.value(context)
end