Last active
November 15, 2022 01:59
-
-
Save rodrigorrch/a8499ee37319381262df75267b1b8511 to your computer and use it in GitHub Desktop.
Estudando padrões
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 AbacaxiMaduro | |
def initialize | |
[ | |
vitamina_a | |
vitamina_b | |
] | |
end | |
private | |
def vitamina_a | |
end | |
def vitamina_b | |
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
module FruitRules | |
OPTIONS = { | |
abacaxi_verde: AbacaxiVerde, | |
abacaxi_maduro: AbacaxiMaduro, | |
abacaxi_estragado: AbacaxiEstragado, | |
... | |
} | |
def self.strategy(kind, status) | |
OPTIONS.fetch("#{kind}_#{status}") | |
end | |
end | |
# Chama o metodo | |
FruitRules.strategy('abacaxi', 'maduro') |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment