Class: Stackdo::Environment

Inherits:
Object
  • Object
show all
Defined in:
lib/stackdo.rb

Instance Attribute Summary collapse

Class Method Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(variables:) ⇒ Environment

Returns a new instance of Environment.



45
46
47
# File 'lib/stackdo.rb', line 45

def initialize(variables:)
  @variables = variables
end

Instance Attribute Details

#variablesObject (readonly)

Returns the value of attribute variables.



33
34
35
# File 'lib/stackdo.rb', line 33

def variables
  @variables
end

Class Method Details

.from_binding(binding) ⇒ Object



35
36
37
38
39
40
41
42
43
# File 'lib/stackdo.rb', line 35

def self.from_binding(binding)
  local_variables = binding.local_variables.map do |local|
    Variable.new(local, binding.local_variable_get(local))
  end

  Environment.new(
    variables: local_variables,
  )
end