Class: Symbolic::Method

Inherits:
Operatable show all
Defined in:
lib/symbolic/method.rb

Instance Method Summary collapse

Methods inherited from Operatable

#+@, #-@

Constructor Details

#initialize(variable, operation) ⇒ Method

Returns a new instance of Method.



3
4
5
# File 'lib/symbolic/method.rb', line 3

def initialize(variable, operation)
  @variable, @operation = variable, operation
end

Instance Method Details

#to_sObject



7
8
9
# File 'lib/symbolic/method.rb', line 7

def to_s
  "#{@operation}(#{@variable})"
end

#undefined_variablesObject



15
16
17
# File 'lib/symbolic/method.rb', line 15

def undefined_variables
  @variable.undefined_variables
end

#valueObject



11
12
13
# File 'lib/symbolic/method.rb', line 11

def value
  Math.send @operation, @variable.value if undefined_variables.empty?
end