Class: Stackdo::Frame

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(location:, method_reference:, environment:) ⇒ Frame

Returns a new instance of Frame.



65
66
67
68
69
# File 'lib/stackdo.rb', line 65

def initialize(location:, method_reference:, environment:)
  @location = location
  @method_reference = method_reference
  @environment = environment
end

Instance Attribute Details

#environmentObject (readonly)

Returns the value of attribute environment.



51
52
53
# File 'lib/stackdo.rb', line 51

def environment
  @environment
end

#locationObject (readonly)

Returns the value of attribute location.



51
52
53
# File 'lib/stackdo.rb', line 51

def location
  @location
end

#method_referenceObject (readonly)

Returns the value of attribute method_reference.



51
52
53
# File 'lib/stackdo.rb', line 51

def method_reference
  @method_reference
end

Class Method Details

.from_binding(binding) ⇒ Object



53
54
55
56
57
58
59
60
61
62
63
# File 'lib/stackdo.rb', line 53

def self.from_binding(binding)
  file = binding.eval("__FILE__")
  line = binding.eval("__LINE__")
  method_name = binding.eval("__method__")

  Stackdo::Frame.new(
    location: Location.new(file, line),
    method_reference: MethodReference.new(binding.receiver, method_name),
    environment: Environment.from_binding(binding)
  )
end