Last active
December 17, 2015 13:49
-
-
Save rajraj/5619812 to your computer and use it in GitHub Desktop.
This file contains 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
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