0
0

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?

More than 5 years have passed since last update.

code is required by aaron patterson

Last updated at Posted at 2016-09-15

vagrant@precise64:~/data$ pry
[1] pry(main)> gem_original_require "eventmachine"
LoadError: cannot load such file -- eventmachine
from (pry):1:in `require'
[2] pry(main)> gem "eventmachine"
=> true
[3] pry(main)> gem_original_require "eventmachine"
=> true
[4] pry(main)> EventMachine
=> EventMachine
[5] pry(main)> 
  • call-seq:
  • require(name)    -> true or false
    
  • Loads the given +name+, returning +true+ if successful and +false+ if the
  • feature is already loaded.
  • If the filename does not resolve to an absolute path, it will be searched
  • for in the directories listed in $LOAD_PATH ($:).
  • If the filename has the extension ".rb", it is loaded as a source file; if
  • the extension is ".so", ".o", or ".dll", or the default shared library
  • extension on the current platform, Ruby loads the shared library as a
  • Ruby extension. Otherwise, Ruby tries adding ".rb", ".so", and so on
  • to the name until found. If the file named cannot be found, a LoadError
  • will be raised.
  • For Ruby extensions the filename given may use any shared library
  • extension. For example, on Linux the socket extension is "socket.so" and
  • require 'socket.dll' will load the socket extension.
  • The absolute path of the loaded file is added to
  • $LOADED_FEATURES ($"). A file will not be
  • loaded again if its path already appears in $". For example,
  • require 'a'; require './a' will not load a.rb
  • again.
  • require "my-library.rb"
  • require "db-driver"
  • Any constants or globals within the loaded source file will be available
  • in the calling program's global namespace. However, local variables will
  • not be propagated to the loading environment.

vagrant@precise64:~/data$ cat foo.rb 
require 'bar'
puts a
vagrant@precise64:~/data$ cat bar.rb 
a = 12
vagrant@precise64:~/data$ ruby -I . foo.rb
foo.rb:2:in `<main>': undefined local variable or method `a' for main:Object (NameError)

0
0
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
0
0

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?