Skip to content

Instantly share code, notes, and snippets.

@rajraj
Last active December 17, 2015 13:49
Show Gist options
  • Save rajraj/5619812 to your computer and use it in GitHub Desktop.
Save rajraj/5619812 to your computer and use it in GitHub Desktop.
module FormatAttributes
def formats(*attributes)
@format_attributes = attributes
end
def format_attributes
@format_attributes
end
end
module Formatter
def display
self.class.format_attributes.each do |a|
puts "[#{a.to_s.upcase}] #{send(a)}"
end
end
end
class Resume
extend FormatAttributes
include Formatter
attr_accessor :name, :email, :telephone
formats :name, :email, :telephone
end
r = Resume.new
r.name = "Rajesh"
r.email = "[email protected]"
r.telephone = "02380 665571"
r.display
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment