Skip to content

Instantly share code, notes, and snippets.

@Sihui
Last active August 5, 2017 18:11
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save Sihui/ce66bc942037ae445cdb7230bbc3bd54 to your computer and use it in GitHub Desktop.
Save Sihui/ce66bc942037ae445cdb7230bbc3bd54 to your computer and use it in GitHub Desktop.
Design Pattern: Composite and Group Messaging
class PersonContact
attr_reader :title, :number
def initialize(title, number)
@title = title
@number = number
end
def message(text)
puts "Messaging #{title}(#{number}): "
puts " #{text}"
end
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment