Skip to content

Instantly share code, notes, and snippets.

Created June 13, 2012 11:22
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save anonymous/2923528 to your computer and use it in GitHub Desktop.
Save anonymous/2923528 to your computer and use it in GitHub Desktop.
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