Skip to content

Instantly share code, notes, and snippets.

@kopylovvlad
Created May 14, 2017 09:41
Show Gist options
  • Save kopylovvlad/f3a67493f3e50678d880e246b4231af8 to your computer and use it in GitHub Desktop.
Save kopylovvlad/f3a67493f3e50678d880e246b4231af8 to your computer and use it in GitHub Desktop.
module Coffee
class Espresso
def initialize
@ingredients = {
espresso: true
}
end
end
class EspressoMacchiato
def initialize
@ingredients = {
espresso: true,
milk_foam: true
}
end
end
class EspressoConPanna
def initialize
@ingredients = {
espresso: true,
whipped_cream: true
}
end
end
class CaffeLatte
def initialize
@ingredients = {
espresso: true,
milk_foam: true,
steamed_milk: true
}
end
end
class FlatWhite
def initialize
@ingredients = {
espresso: true,
steamed_milk: true
}
end
end
class CaffeeMocha
def initialize
@ingredients = {
espresso: true,
whipped_cream: true,
steamed_milk: true,
chokolate_syrup: true
}
end
end
class Americano
def initialize
@ingredients = {
espresso: true,
hot_water: true
}
end
end
end
module CoffeeMaker
def self.make_coffee(coffee)
ingredients = coffee.ingredients
#
# and some lines of code
#
return cup_of_coffee(ingredients)
end
end
CoffeeMaker.make_coffee Coffee::Espresso.new
CoffeeMaker.make_coffee Coffee::EspressoMacchiato.new
CoffeeMaker.make_coffee Coffee::EspressoConPanna.new
CoffeeMaker.make_coffee Coffee::CaffeLatte.new
CoffeeMaker.make_coffee Coffee::FlatWhite.new
CoffeeMaker.make_coffee Coffee::CaffeeMocha.new
CoffeeMaker.make_coffee Coffee::Americano.new
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment