411 REFERENCE · Wikibooks
Ruby Programming/Standard Library/Tracer
Reference material by Wikibooks contributors. This retains its source identity and is not 411 news reporting.
// Chaveiro Magali - estilo simples
$fn=100;
// Base (formato circular)
difference() {
union() {
// Cabeça
translate([0,0,0])
cylinder(h=4, d=50);
// Cabelo (topo)
translate([0,10,0])
sphere(r=22);
// Orelhas
translate([-18,5,0])
sphere(r=6);
translate([18,5,0])
sphere(r=6);
}
// Olhos
translate([-8,10,1])
cylinder(h=5, d=5);
translate([8,10,1])
cylinder(h=5, d=5);
// Boca
translate([0,0,1])
cylinder(h=5, d=10);
// Furo do chaveiro
translate([0,28,0])
cylinder(h=5, d=6);
}
Tracer
Ruby's built-in "tracer.rb" file shows you method by method which lines are called.
To use it:
ruby -rtracer script_name.rb
for example, the following code:
class A
def setup
@instvar = 1
end
def go
var = 2
4.times do |@instvar|
@instvar=@instvar*var end # <font color="#007700">#=>0,2,4,6 last assignment of @instvar is 6</font>
end
end
instance = A.new
instance.setup
instance.go
produces the following result:
C:\dev\digitalarchive_trunk>ruby -rtracer test.rb
#0:test.rb:1::-: class A
#0:test.rb:1:Class:>: class A
#0:test.rb:1:Class:<: class A
#0:test.rb:1::C: class A
#0:test.rb:2::-: def setup
#0:test.rb:2:Module:>: def setup
#0:test.rb:2:Module:<: def setup
#0:test.rb:5::-: def go
#0:test.rb:5:Module:>: def go
#0:test.rb:5:Module:<: def go
#0:test.rb:1::E: class A
#0:test.rb:11::-: instance = A.new
#0:test.rb:11:Class:>: instance = A.new
#0:test.rb:11:Object:>: instance = A.new
#0:test.rb:11:Object:<: instance = A.new
#0:test.rb:11:Class:<: instance = A.new
#0:test.rb:12::-: instance.setup
#0:test.rb:2:A:>: def setup
#0:test.rb:3:A:-: @instvar = 1`
#0:test.rb:4:A:<: end`
#0:test.rb:13::-: instance.go
#0:test.rb:5:A:>: def go
#0:test.rb:6:A:-: var = 2
#0:test.rb:7:A:-: 4.times do |@instvar|
#0:test.rb:7:Integer:>: 4.times do |@instvar|
#0:test.rb:8:A:-: @instvar=@instvar*var end # <font color="#007700">#=>0,2,4,6 last assignment of @instvar is 6</font>
#0:test.rb:8:Fixnum:>: @instvar=@instvar*var end # <font color="#007700">#=>0,2,4,6 last assignment of @instvar is 6</font>
#0:test.rb:8:Fixnum:<: @instvar=@instvar*var end # <font color="#007700">#=>0,2,4,6 last assignment of @instvar is 6</font>
#0:test.rb:8:A:-: @instvar=@instvar*var end # <font color="#007700">#=>0,2,4,6 last assignment of @instvar is 6</font>
#0:test.rb:8:Fixnum:>: @instvar=@instvar*var end # <font color="#007700">#=>0,2,4,6 last assignment of @instvar is 6</font>
#0:test.rb:8:Fixnum:<: @instvar=@instvar*var end # <font color="#007700">#=>0,2,4,6 last assignment of @instvar is 6</font>
#0:test.rb:8:A:-: @instvar=@instvar*var end # <font color="#007700">#=>0,2,4,6 last assignment of @instvar is 6</font>
#0:test.rb:8:Fixnum:>: @instvar=@instvar*var end # <font color="#007700">#=>0,2,4,6 last assignment of @instvar is 6</font>
#0:test.rb:8:Fixnum:<: @instvar=@instvar*var end # <font color="#007700">#=>0,2,4,6 last assignment of @instvar is 6</font>
#0:test.rb:8:A:-: @instvar=@instvar*var end # <font color="#007700">#=>0,2,4,6 last assignment of @instvar is 6</font>
#0:test.rb:8:Fixnum:>: @instvar=@instvar*var end # <font color="#007700">#=>0,2,4,6 last assignment of @instvar is 6</font>
#0:test.rb:8:Fixnum:<: @instvar=@instvar*var end # <font color="#007700">#=>0,2,4,6 last assignment of @instvar is 6</font>
#0:test.rb:7:Integer:<: 4.times do |@instvar|
#0:test.rb:6:A:<: var = 2