Skip to content

Instantly share code, notes, and snippets.

Created June 13, 2012 11:00
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/2923435 to your computer and use it in GitHub Desktop.
Save anonymous/2923435 to your computer and use it in GitHub Desktop.
#!/home/user1/.rvm/rubies/ruby-1.9.3-p194/bin/ruby
require 'hola/translator'
module Hola
def hi(language = :english)
translator = Translator.new(language)
translator.hi
end
end
include Hola
puts Hola::hi(:english)
lib/hola/translator.rb=>
class 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$ ruby -Ilib hola.rb
/home/user1/.rvm/rubies/ruby-1.9.3-p194/lib/ruby/site_ruby/1.9.1/rubygems/custom_require.rb:36:in `require': cannot load such file -- hola/translator (LoadError)
from /home/user1/.rvm/rubies/ruby-1.9.3-p194/lib/ruby/site_ruby/1.9.1/rubygems/custom_require.rb:36:in `require'
from hola.rb:3:in `<main>'
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment