On Mar 30, 8:03  򮮮
> Hello,
>
> I am having trouble understanding the difference between require and
> include. Also i need to know how to import a certain function or class
> into my current namespace.
>
> Now before i go any further i should explain that i am a Python
> programmer and i understand that whilst Ruby and Python share some
> similarities there are major differences between the languages,  
> that is what seems to have me stumped here.
> [...]
>
> Ok, i know Ruby is different, so tell me how i do the same thing only
> in Ruby terms. Specifically i need to bring in a function that resides
> in a module in a different file. How do i do this?

I can relate to your situation, since I also come from a Python
background.  It is probably good to read up on docs a bit, but you
might also find the following examples useful for experimentation.

I think the answer to your specific question is shown by the use of
Hello2::hello_world2() below.  Note that it is hello2.rb that actually
"namespaces" the function (and makes it a public module function), not
the act of calling "require" itself.  This is very different from
Python, of course.

    ::::::::::::::
    foo.rb
    ::::::::::::::
    # require without modules
    require 'hello1'
    hello_world1()

    # require with modules in the
    # other file (see hello2.rb)
    require 'hello2'
    Hello2::hello_world2()

    # re-opening module
    module Hello2
      def goodbye()
        puts 'goodbye'
      end
      module_function :goodbye
    end
    Hello2::goodbye()

    # on-the-fly modules
    hello3 = Module.new do
      def hello_world3()
        puts 'hello world 3'
      end
      module_function :hello_world3

      def obj_method()
        puts 'obj_method'
      end
    end

    hello3::hello_world3()
    obj = 'foo'
    obj.extend(hello3)
    obj.obj_method()


    ::::::::::::::
    hello1.rb
    ::::::::::::::
    def hello_world1
        puts 'hello world 1'
    end

    ::::::::::::::
    hello2.rb
    ::::::::::::::
    module Hello2
      def hello_world2
        puts 'hello world 2'
      end
      module_function :hello_world2
    end