Class: RainforestRubyRuntime::Variables::StaticVariableRegistry
- Inherits:
-
Object
- Object
- RainforestRubyRuntime::Variables::StaticVariableRegistry
- Defined in:
- lib/rainforest_ruby_runtime/variables/registry.rb
Instance Method Summary collapse
- #[](name) ⇒ Object
- #has_variable?(name) ⇒ Boolean
-
#initialize(variables) ⇒ StaticVariableRegistry
constructor
A new instance of StaticVariableRegistry.
- #register ⇒ Object
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
37 38 39 |
# File 'lib/rainforest_ruby_runtime/variables/registry.rb', line 37 def has_variable?(name) @variables.has_key?(name.to_s) end |
#register ⇒ Object
45 46 47 |
# File 'lib/rainforest_ruby_runtime/variables/registry.rb', line 45 def register(*) # noop end |