Class: Keisan::AST::Block

Inherits:
Node
  • Object
show all
Defined in:
lib/keisan/ast/block.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Methods inherited from Node

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

Constructor Details

#initialize(child) ⇒ Block

Returns a new instance of Block.



6
7
8
# File 'lib/keisan/ast/block.rb', line 6

def initialize(child)
  @child = child
end

Instance Attribute Details

#childObject (readonly)

Returns the value of attribute child.



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

def child
  @child
end

Instance Method Details

#deep_dupObject



20
21
22
23
24
25
26
27
# File 'lib/keisan/ast/block.rb', line 20

def deep_dup
  dupped = dup
  dupped.instance_variable_set(
    :@child,
    dupped.child.deep_dup
  )
  dupped
end

#evaluate(context = nil) ⇒ Object



34
35
36
37
# File 'lib/keisan/ast/block.rb', line 34

def evaluate(context = nil)
  local = get_local_context(context)
  child.evaluate(local)
end

#replace(variable, replacement) ⇒ Object



44
45
46
# File 'lib/keisan/ast/block.rb', line 44

def replace(variable, replacement)
  self
end

#simplify(context = nil) ⇒ Object



39
40
41
42
# File 'lib/keisan/ast/block.rb', line 39

def simplify(context = nil)
  local = get_local_context(context)
  child.simplify(local)
end

#to_sObject



48
49
50
# File 'lib/keisan/ast/block.rb', line 48

def to_s
  "{#{child}}"
end

#unbound_functions(context = nil) ⇒ Object



15
16
17
18
# File 'lib/keisan/ast/block.rb', line 15

def unbound_functions(context = nil)
  local = get_local_context(context)
  child.unbound_functions(local)
end

#unbound_variables(context = nil) ⇒ Object



10
11
12
13
# File 'lib/keisan/ast/block.rb', line 10

def unbound_variables(context = nil)
  local = get_local_context(context)
  child.unbound_variables(local)
end

#value(context = nil) ⇒ Object



29
30
31
32
# File 'lib/keisan/ast/block.rb', line 29

def value(context = nil)
  local = get_local_context(context)
  child.evaluated(local).value(local)
end