Skip to content

Instantly share code, notes, and snippets.

@Sihui
Last active October 26, 2017 00:46
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/a8aced2547286a90e455b2f3fc879b59 to your computer and use it in GitHub Desktop.
Save Sihui/a8aced2547286a90e455b2f3fc879b59 to your computer and use it in GitHub Desktop.
Design Pattern: Adapter and Power Adapter
class TypeAPlug
attr_accessor :electricity, :voltage
def initialize
@electricity = nil
@voltage = nil
end
def plug_into(outlet)
self.electricity = outlet.type_a_elec
self.voltage = outlet.type_a_voltage
end
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment