Created
June 13, 2012 11:22
-
-
Save anonymous/2923528 to your computer and use it in GitHub Desktop.
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
mygem/lib/hola.rb=> | |
#!/home/user1/.rvm/rubies/ruby-1.9.3-p194/bin/ruby | |
class Hola | |
def self.hi(language = :english) | |
translator = Translator.new(language) | |
translator.hi | |
end | |
end | |
require_relative 'hola/translator' | |
puts Hola.hi(:english) | |
mygem/lib/hola/translator.rb=> | |
class Hola::Translator | |
def initialize(language) | |
@language = language | |
end | |
def hi | |
case @language | |
when :spanish | |
"hola mundo" | |
else | |
"hello world" | |
end | |
end | |
end | |
user1@mybox:~/tempgems/mygem/lib$ ./hola.rb | |
hello world |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment