Class: RemoteRuby::LocalsExtractor
- Inherits:
-
Object
- Object
- RemoteRuby::LocalsExtractor
- Defined in:
- lib/remote_ruby/locals_extractor.rb
Overview
Extracts local variable from given context
Instance Attribute Summary collapse
-
#block ⇒ Object
readonly
Returns the value of attribute block.
-
#ignore_types ⇒ Object
readonly
Returns the value of attribute ignore_types.
Instance Method Summary collapse
-
#initialize(block, ignore_types: []) ⇒ LocalsExtractor
constructor
A new instance of LocalsExtractor.
- #locals ⇒ Object
Constructor Details
#initialize(block, ignore_types: []) ⇒ LocalsExtractor
Returns a new instance of LocalsExtractor.
8 9 10 11 |
# File 'lib/remote_ruby/locals_extractor.rb', line 8 def initialize(block, ignore_types: []) @block = block @ignore_types = Array(ignore_types) end |
Instance Attribute Details
#block ⇒ Object (readonly)
Returns the value of attribute block.
6 7 8 |
# File 'lib/remote_ruby/locals_extractor.rb', line 6 def block @block end |
#ignore_types ⇒ Object (readonly)
Returns the value of attribute ignore_types.
6 7 8 |
# File 'lib/remote_ruby/locals_extractor.rb', line 6 def ignore_types @ignore_types end |
Instance Method Details
#locals ⇒ Object
13 14 15 16 17 18 19 20 21 22 23 24 |
# File 'lib/remote_ruby/locals_extractor.rb', line 13 def locals locals = {} block.binding.local_variables.each do |name| value = block.binding.eval(name.to_s) next if ignored_type?(value) locals[name] = value end locals end |