Created
September 30, 2011 21:36
-
-
Save prodis/1255032 to your computer and use it in GitHub Desktop.
Ruby Fundamental - Módulos como namespaces
This file contains 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 FreteCorreios | |
def calcular | |
# Implementação do método | |
end | |
end | |
class FreteFedex | |
def calcular | |
# Implementação do método | |
end | |
end | |
frete_correios = FreteCorreios.new | |
frete_correios.calcular | |
frete_fedex = FreteFedex.new | |
frete_fedex.calcular |
This file contains 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 Frete | |
class Correios | |
def calcular | |
# Implementação do método | |
end | |
end | |
class Fedex | |
def calcular | |
# Implementação do método | |
end | |
end | |
end |
This file contains 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
frete_correios = Frete::Correios.new | |
frete_correios.calcular | |
frete_fedex = Frete::Fedex.new | |
frete_fedex.calcular |
This file contains 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 Frete | |
PESO_MINIMO = 0.3 | |
class Correios | |
def calcular | |
# Implementação do método | |
end | |
end | |
class Fedex | |
def calcular | |
# Implementação do método | |
end | |
end | |
end |
This file contains 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 Frete | |
PESO_MINIMO = 0.3 | |
class Correios | |
def calcular | |
# Implementação do método | |
PESO_MINIMO # Usando uma constante do módulo | |
end | |
end | |
class Fedex | |
def calcular | |
# Implementação do método | |
PESO_MINIMO # Usando uma constante do módulo | |
end | |
end | |
end | |
puts Frete::PESO_MINIMO # => 0.3 |
This file contains 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
# frete.rb | |
module Frete | |
PESO_MINIMO = 0.3 | |
end |
This file contains 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
# frete/correios.rb | |
module Frete | |
class Correios | |
def calcular | |
# Implementação do método | |
end | |
end | |
end |
This file contains 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
# frete/fedex.rb | |
module Frete | |
class Fedex | |
def calcular | |
# Implementação do método | |
end | |
end | |
end |
This file contains 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
# frete/correios.rb | |
class Frete::Correios | |
def calcular | |
# Implementação do método | |
end | |
end |
This file contains 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
# frete/fedex.rb | |
class Frete::Fedex | |
def calcular | |
# Implementação do método | |
end | |
end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment