class Basic101::ArrayReference
Public Class Methods
new(identifier, arguments)
click to toggle source
Calls superclass method
# File lib/basic101/array_reference.rb, line 9 def initialize(identifier, arguments) super(identifier) @arguments = arguments end
Public Instance Methods
assign(runtime, value)
click to toggle source
# File lib/basic101/array_reference.rb, line 18 def assign(runtime, value) get_array(runtime).set(indices(runtime), value) end
dimension_array(runtime)
click to toggle source
# File lib/basic101/array_reference.rb, line 22 def dimension_array(runtime) get_array(runtime).dimension(indices(runtime)) end
eval(runtime)
click to toggle source
# File lib/basic101/array_reference.rb, line 14 def eval(runtime) get_array(runtime).get(indices(runtime)) end
Protected Instance Methods
state()
click to toggle source
Calls superclass method
# File lib/basic101/array_reference.rb, line 28 def state super + [@arguments] end
Private Instance Methods
argument_values(runtime)
click to toggle source
# File lib/basic101/array_reference.rb, line 46 def argument_values(runtime) @arguments.map do |argument| argument.eval(runtime) end end
get_array(runtime)
click to toggle source
# File lib/basic101/array_reference.rb, line 34 def get_array(runtime) runtime.get_array(@identifier, num_dimensions) end
indices(runtime)
click to toggle source
# File lib/basic101/array_reference.rb, line 42 def indices(runtime) argument_values(runtime).map(&:to_integer).map(&:to_i) end
num_dimensions()
click to toggle source
# File lib/basic101/array_reference.rb, line 38 def num_dimensions @arguments.size end