Skip to content

Instantly share code, notes, and snippets.

@codeprimate
Last active December 16, 2015 22:19
Show Gist options
  • Save codeprimate/5506708 to your computer and use it in GitHub Desktop.
Save codeprimate/5506708 to your computer and use it in GitHub Desktop.
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