Class: Keisan::AST::Indexing

Inherits:
UnaryOperator show all
Defined in:
lib/keisan/ast/indexing.rb

Instance Attribute Summary collapse

Attributes inherited from Parent

#children

Instance Method Summary collapse

Constructor Details

#initialize(child, arguments = []) ⇒ Indexing

Returns a new instance of Indexing.



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

def initialize(child, arguments = [])
  @children = [child]
  @arguments = arguments
end

Instance Attribute Details

#argumentsObject (readonly)

Returns the value of attribute arguments.



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

def arguments
  @arguments
end

Instance Method Details

#value(context = nil) ⇒ Object



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

def value(context = nil)
  return children.first.value(context).send(:[], *arguments.map {|arg| arg.value(context)})
end