Skip to content

anonymous /block_woes_ref1

Embed URL

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
class ActivityLogger
def self.reports
@reports ||= []
end
def self.log(&block)
class_eval &block
end
def self.activity(date, &block)
activity = Activity.new(date)
activity.instance_eval &block
reports << activity
end
def self.report
reports.each do |rep|
puts rep.inspect
end
end
end
class Activity
def initialize(date)
@date = date
@logs = []
end
def eat(&block)
#@logs << Log.new(Eat, &block)
@logs << Log.new(Eat) {|l| l.instance_eval &block}
end
end
class Log
attr_accessor :activity, :duration, :priority
def initialize(activity, &block)
@activity = activity
yield self
end
end
class Eat; end
ActivityLogger.log do
activity('27-06-2012') do
eat do #|act|
duration = 15
priority = 5
end
end
end
ActivityLogger.report
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Something went wrong with that request. Please try again.