The Artima Developer Community
Sponsored Link

Ruby Buzz Forum
MuffDaddy! The Ultimate Rapper! (Word)

0 replies on 1 page.

Welcome Guest
  Sign In

Go back to the topic listing  Back to Topic List Click to reply to this topic  Reply to this Topic Click to search messages in this forum  Search Forum Click for a threaded view of the topic  Threaded View   
Previous Topic   Next Topic
Flat View: This topic has 0 replies on 1 page
Ryan Davis

Posts: 651
Nickname: zenspider
Registered: Oct, 2004

Ryan Davis is a ruby nerd.
MuffDaddy! The Ultimate Rapper! (Word) Posted: Feb 25, 2005 12:13 AM
Reply to this message Reply

This post originated from an RSS feed registered with Ruby Buzz by Ryan Davis.
Original Post: MuffDaddy! The Ultimate Rapper! (Word)
Feed Title: Polishing Ruby
Feed URL: http://blog.zenspider.com/index.rdf
Feed Description: Musings on Ruby and the Ruby Community...
Latest Ruby Buzz Posts
Latest Ruby Buzz Posts by Ryan Davis
Latest Posts From Polishing Ruby

Advertisement
module CheapoTracer

  include MuffDaddy

  RAP_METHOD_NAME = :__trace__

  def __trace__
    @__trace = 0 unless defined? @__trace
    print "  " * @__trace
    print "#{@__trace}: "
    @__trace += 1
    yield
    @__trace -= 1
  end

end

class Untraced
  def something
    puts "Miiiiisery!"
    something_else
  end

  def something_else
    puts "Decay!"
  end
end

class Traced
  include CheapoTracer

  def method1
    puts "I'm dead too!"
  end
end

w1 = Untraced.new
w1.something

w1.extend CheapoTracer
w1.something

w2 = Untraced.new
w2.something

w3 = Traced.new
w3.method1

outputs:

Miiiiisery!
Decay!
0: Miiiiisery!
  1: Decay!
Miiiiisery!
Decay!
0: I'm dead too!

Read: MuffDaddy! The Ultimate Rapper! (Word)

Topic: Serving the koolaid with the facts Previous Topic   Next Topic Topic: Reading the process table

Sponsored Links



Google
  Web Artima.com   

Copyright © 1996-2019 Artima, Inc. All Rights Reserved. - Privacy Policy - Terms of Use