#!/usr/bin/env ruby -Ku
# -*- encoding: utf-8 -*-
class Task
attr_accessor :name, :alarm, :coffee, :out
def initialize
end
def task(task_name)
@name = task_name
yield(self)
end
end
my_task = Task.new
my_task.instance_eval(DATA.read)
p my_task.name
p my_task.alarm
p my_task.coffee
p my_task.out
__END__
task 'morning' do |t|
t.alarm = '7:00'
t.coffee = :blue_mountain
t.out = '9:00'
end
Sunday, May 02, 2010
ruby DSL
Subscribe to:
Post Comments (Atom)
No comments:
Post a Comment