Class: RainforestRubyRuntime::Variables::StaticVariableRegistry

Inherits:
Object
  • Object
show all
Defined in:
lib/rainforest_ruby_runtime/variables/registry.rb

Instance Method Summary collapse

Constructor Details

#initialize(variables) ⇒ StaticVariableRegistry

Returns a new instance of StaticVariableRegistry.



26
27
28
29
30
31
32
33
34
35
# File 'lib/rainforest_ruby_runtime/variables/registry.rb', line 26

def initialize(variables)
  @variables = variables.inject({}) do |variables, (name, var_and_values)|
    scope = Scope.new(name)
    var_and_values.each do |name, value|
      scope.define_variable(name.to_sym) { value }
    end
    variables[name] = scope
    variables
  end
end

Instance Method Details

#[](name) ⇒ Object



41
42
43
# File 'lib/rainforest_ruby_runtime/variables/registry.rb', line 41

def [](name)
  @variables[name.to_s]
end

#has_variable?(name) ⇒ Boolean

Returns:

  • (Boolean)


37
38
39
# File 'lib/rainforest_ruby_runtime/variables/registry.rb', line 37

def has_variable?(name)
  @variables.has_key?(name.to_s)
end

#registerObject



45
46
47
# File 'lib/rainforest_ruby_runtime/variables/registry.rb', line 45

def register(*)
  # noop
end