Created
July 26, 2014 15:22
-
-
Save patrickmaciel/008232bcb4b2cc3ce668 to your computer and use it in GitHub Desktop.
Blog - Aprendendo Ruby - Modules
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
# encoding utf-8 | |
module Ataques | |
def ataqueEspecial | |
puts "Ataque especial #{fraseDeImpacto}" | |
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
# encoding utf-8 | |
module Ficha | |
class Personagem | |
attr_reader :nome, :fraseDeImpacto | |
attr_accessor :arma | |
def initialize nome, fraseDeImpacto = nil | |
@nome = nome | |
@fraseDeImpacto = fraseDeImpacto | |
@arma = Arma.new "Clava de madeira", "Concentrado" | |
end | |
end | |
class Arma | |
attr_reader :nome, :fraseDeImpacto | |
def initialize nome, fraseDeImpacto = nil | |
@nome = nome | |
@fraseDeImpacto = fraseDeImpacto | |
end | |
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
# encoding utf-8 | |
require_relative "ficha" | |
spartacus = Ficha::Personagem.new "Spartacus", "Vorpal!!!!! RWWWWRRRRAAWWWW" | |
spartacus.ataqueEspecial | |
spartacus.arma.ataqueEspecial |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment