Created
          September 29, 2018 03:37 
        
      - 
      
- 
        Save rachidcalazans/d85fbb2178f9e5d66040beae35033311 to your computer and use it in GitHub Desktop. 
    Design Patterns in Ruby - Template Method
  
        
  
    
      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 CaffeineBeverage | |
| def prepare_recipe | |
| # Abstract method without implementation | |
| end | |
| def boil_water | |
| puts 'boil water' | |
| end | |
| def pour_in_cup | |
| puts 'pour in cup' | |
| end | |
| end | |
| class Cappuccino < CaffeineBeverage | |
| def prepare_recipe | |
| boil_water | |
| brew_cappuccino_grinds | |
| pour_in_cup | |
| add_sugar | |
| end | |
| def brew_cappuccino_grinds | |
| puts 'brew cappuccino grinds' | |
| end | |
| def add_sugar | |
| puts 'add sugar' | |
| end | |
| end | |
| class Tea < CaffeineBeverage | |
| def prepare_recipe | |
| boil_water | |
| steep_the_bag | |
| pour_in_cup | |
| add_lemon | |
| end | |
| def steep_the_bag | |
| puts 'steep the bag' | |
| end | |
| def add_lemon | |
| puts 'add lemon' | |
| end | |
| end | 
  
    Sign up for free
    to join this conversation on GitHub.
    Already have an account?
    Sign in to comment