Module: RubyNodeReflector
- Included in:
- AssertAgile
- Defined in:
- lib/ruby_reflector.rb
Defined Under Namespace
Modules: Coulor Classes: RubyReflector
Instance Method Summary collapse
-
#reflect(&block) ⇒ Object
This reflects a block of code, by evaluating it, reflecting its source, and reflecting all its intermediate values.
-
#reflect_source(&block) ⇒ Object
This reflects a block of code, /without/ evaluating it.
-
#reflect_string(string) ⇒ Object
This compiles a string and reflects its source…
Instance Method Details
#reflect(&block) ⇒ Object
This reflects a block of code, by evaluating it, reflecting its
source, and reflecting all its intermediate values
35 36 37 38 39 40 41 42 43 44 45 46 |
# File 'lib/ruby_reflector.rb', line 35 def reflect(&block) result = block.call rf = RubyReflector.new(block) begin waz = rf.colorize? rf.colorize(false) return rf.result + arrow_result(result) + "\n" + rf.format_evaluations ensure rf.colorize(waz) end end |
#reflect_source(&block) ⇒ Object
This reflects a block of code, /without/ evaluating it.
The function only compiles the source and reflects it as
a string of disassembled Ruby
57 58 59 |
# File 'lib/ruby_reflector.rb', line 57 def reflect_source(&block) return RubyReflector.new(block, false).result end |
#reflect_string(string) ⇒ Object
This compiles a string and reflects its source…
as another string.
64 65 66 67 68 69 70 |
# File 'lib/ruby_reflector.rb', line 64 def reflect_string(string) rf = RubyReflector.new(proc{}) rf.reflect_values = false # pp string.parse_to_nodes.transform got = rf.reflect_nodes(string.parse_to_nodes) return got end |