Sha256: 63ebbc93341cc208d9951f6556ff3cfcd41543be008c358036a27604b4c417bc

Contents?: true

Size: 859 Bytes

Versions: 5

Compression:

Stored size: 859 Bytes

Contents

#          Copyright (c) 2008 Michael Fellinger m.fellinger@gmail.com
# All files in this distribution are subject to the terms of the MIT license.

module Ramaze
  module CoreExtensions
    # Extensions for Object
    module Object
      unless defined?(__DIR__)

        # This is similar to +__FILE__+ and +__LINE__+, and returns a String
        # representing the directory of the current file is.
        # Unlike +__FILE__+ the path returned is absolute.
        #
        # This method is convenience for the
        #  File.expand_path(File.dirname(__FILE__))
        # idiom.
        def __DIR__(*args)
          filename = caller[0][/^(.*):/, 1]
          dir = File.expand_path(File.dirname(filename))
          ::File.expand_path(::File.join(dir, *args.map{|a| a.to_s}))
        end
      end
    end # Object
  end # CoreExtensions
end # Ramaze

Version data entries

5 entries across 5 versions & 1 rubygems

Version Path
ramaze-2023.01.06 lib/ramaze/snippets/object/__dir__.rb
ramaze-2012.12.08 lib/ramaze/snippets/object/__dir__.rb
ramaze-2012.12.08b lib/ramaze/snippets/object/__dir__.rb
ramaze-2012.04.14 lib/ramaze/snippets/object/__dir__.rb
ramaze-2012.03.07 lib/ramaze/snippets/object/__dir__.rb