Sha256: a3d7386461a325509e35e60c07ee4b2651570394ecbf28216041ad0beebe433f

Contents?: true

Size: 870 Bytes

Versions: 1

Compression:

Stored size: 870 Bytes

Contents

=Dirge

==Usage

  require 'dirge'
  require_relative '../to_my_file'

Or, the much simpler notation

  require ~'../to_my_file'

annnd.

  class MyAwesomeClass
    autoload_relative :MyConstant, 'my_awesome_class/my_constant'
  end

Again, this could be 

  class MyAwesomeClass
    autoload :MyConstant, ~'my_awesome_class/my_constant'
  end

All of this is powered by the new function:
  
  __DIR__
  
which takes a single line off of <tt>Kernel.caller</tt> and give you back the relative path. Calling __DIR__(caller.first) for instance, will give you the relative path to whoever called you.

There is also a more explicit, and probably, more readable version.

  File.relative(path)

This will convert your path into a relative directory from wherever you are.

  require_relative 'to/my/file'
  
and 

  require File.relative('to/my/file')
  
should be identical.

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
dirge-0.0.4 README.rdoc