Skip to content

Instantly share code, notes, and snippets.

@Sihui
Created August 2, 2017 04:45
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/5b75ec6b1771176fd9559b32c4162b16 to your computer and use it in GitHub Desktop.
Save Sihui/5b75ec6b1771176fd9559b32c4162b16 to your computer and use it in GitHub Desktop.
Design Pattern: Adapter and Power Adapter
class C2AAdapter
attr_reader :type_c_outlet
def initialize(type_c_outlet)
@type_c_outlet = type_c_outlet
end
def type_a_elec
"converting #{type_c_outlet.type_c_elec}"
# some electric circuit conversion
'15A electricity'
end
def type_a_voltage
"converting #{type_c_outlet.type_c_voltage}"
# some electric circuit conversion
'100 - 127 voltages'
end
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment