Created
November 26, 2010 19:00
-
-
Save malev/717092 to your computer and use it in GitHub Desktop.
Include in Ruby
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 MyModule | |
def my_method(variable) | |
puts "the variable is " + variable.to_s | |
end | |
end | |
class Clase | |
include MyModule | |
attr_accessor :value1, :value2 | |
def initialize(value1, value2) | |
@value1 = value1 | |
@value2 = value2 | |
end | |
def one_method | |
puts "hi there!" | |
end | |
def my_method(variable) | |
puts "ahora el codigo estya aqui" | |
end | |
end | |
objeto = Clase.new("one string", "other string") | |
objeto.one_method | |
objeto.my_method("from an interface") | |
# Ejemplo clarísimo de esto: | |
############################ | |
#La clase Array implementa el módulo Ennumerable. | |
#Entonces nosotros podemos llamar al método find, o | |
#first desde un Array, siendo que estos métodos están definidos en el módulo Ennumerable. |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment