This file contains hidden or 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
| netflix_movies = [ | |
| { | |
| title: 'Train to Busan', | |
| year: '2016', | |
| director: 'Yeon Sang-ho', | |
| genre: 'Drama film/Disaster Film', | |
| length: '1h 58m' | |
| }, | |
| { | |
| title: 'The Big Short', |
This file contains hidden or 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
| class OneClickCheckout | |
| attr_reader :checkout_process, :default_address, :default_payment | |
| def initialize(order, default_address, default_payment) | |
| @checkout_process = CheckoutProcess.new(order) | |
| @default_address = default_address | |
| @default_payment = default_payment | |
| end | |
| def click |
This file contains hidden or 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
| class Order | |
| attr_accessor :shipping_address, :payment_method, :items | |
| def initialize(items) | |
| @shipping_address = nil | |
| @payment_method = nil | |
| @items = items | |
| end | |
| def confirm |
This file contains hidden or 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
| class CheckoutProcess | |
| attr_reader :order | |
| def initialize(order) | |
| @order = order | |
| end | |
| def set_shipping_address(address) | |
| order.shipping_address = address | |
| end |
This file contains hidden or 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
| 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 |
This file contains hidden or 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
| class TypeCOutlet | |
| def type_c_elec | |
| '2.5A electricity' | |
| end | |
| def type_c_voltage | |
| '220-240 voltages' | |
| end | |
| end |
This file contains hidden or 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
| class TypeAPlug | |
| attr_accessor :electricity, :voltage | |
| def initialize | |
| @electricity = nil | |
| @voltage = nil | |
| end | |
| def plug_into(outlet) | |
| self.electricity = outlet.type_a_elec |
This file contains hidden or 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
| class ServicePanel | |
| attr_reader :button_a1, :button_a2, :button_b1, :button_b2 | |
| def initialize(a1_service, a2_service, | |
| b1_service, b2_service) | |
| @button_a1 = Button.new(a1_service) | |
| @button_a2 = Button.new(a2_service) | |
| @button_b1 = Button.new(b1_service) | |
| @button_b2 = Button.new(b2_service) | |
| end |
This file contains hidden or 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
| class SpaReservationService | |
| attr_reader :data, :spa_center | |
| def initialize(data) | |
| @data = data | |
| @spa_center = SpaCenter.new | |
| end | |
| def execute | |
| spa_center.reserve(data) |
This file contains hidden or 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
| class Concierge | |
| attr_reader :request_list | |
| def initialize | |
| @request_list = [] | |
| end | |
| def act_on_requests | |
| @request_list.each do |request| | |
| request.execute |