Last active
December 16, 2015 22:19
-
-
Save codeprimate/5506708 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
class Conference | |
FIELDS = [:name, :theme, :training, :conference, :location] | |
FIELDS.each do |f| | |
class_eval do | |
define_method f.to_s do |arg| | |
instance_variable_set "@#{f}", arg | |
end | |
end | |
end | |
def initialize(&block) | |
instance_eval &block | |
printout | |
end | |
def printout | |
FIELDS.each do |f| | |
puts "%s = %s" % [ f, instance_variable_get("@#{f}") ] | |
end | |
end | |
end | |
Conference.new do | |
name "LoneStarRuby Conference 2013" | |
theme ["Design", "Community", "Change"] | |
training "July 18th, 2013" | |
conference "July 19th & 20th, 2013" | |
location "Austin, TX" | |
end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment