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.
6 7 8 9 |
# File 'lib/remote_ruby/locals_extractor.rb', line 6 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.
4 5 6 |
# File 'lib/remote_ruby/locals_extractor.rb', line 4 def block @block end |
#ignore_types ⇒ Object (readonly)
Returns the value of attribute ignore_types.
4 5 6 |
# File 'lib/remote_ruby/locals_extractor.rb', line 4 def ignore_types @ignore_types end |
Instance Method Details
#locals ⇒ Object
11 12 13 14 15 16 17 18 19 20 21 |
# File 'lib/remote_ruby/locals_extractor.rb', line 11 def locals locals = {} local_variable_names.each do |name| value = block.binding.eval(name.to_s) next if ignored_type?(value) locals[name] = value end locals end |