22 Jul '12, 11am

How to get the directory of the current script? - Ruby Forum

> File.dirname(__FILE__) will give you the current file's path. The current file may be accessed with a relative path. If you need the absolute path, make sure you expand it: File.expand_path(File.dirname(__FILE__)) > Also, if I have a module, within a function, how do I get the parent > directory (full path) of that module? If __FILE__ is used in that module, it will refer to the file containing that module. If the module is under your control, you can add a method that provides this: module MyModule def this_file __FILE__ end end Otherwise, as has been noted, since a module name does not have to have any relation to the filename it is in, there is no way (AFAIK) to find the file containing a particular module unless you open the current file and parse for any require or load calls (recursively using the current environment for searching for files) and look for the module...

Full article: http://www.ruby-forum.com/topic/143383

Tweets

Get a

Get a

The adage on this plastic frog-flower knickknack in this taxi is an accurate description of the life of most Bangkok taxi ...

@ironruby um, I get a 404 here

ironruby.net 21 Jul '12, 1pm

Overview Download Documentation Support IronRuby IronRuby Tutorial

Bundler: The best way to manage Ruby applications

gembundler.com 22 Jul '12, 11am

As a result, bundler comes with a --deployment flag that encapsulates the best practices for using bundler in a deployment...

javaparse (0.0.7): Get info from Java files

rubygems.org 22 Jul '12, 5pm

javaparse 0.0.4 Get info from Java files with Ruby install gem install javaparse Download Documentation Subscribe Stats Au...

uninitialized stream (IOError) - Ruby Forum

ruby-forum.com 23 Jul '12, 10am

So I'm getting an unexpected IOError in my code. class ConfigStub < File def initialize(location) unless filename = locati...

A proposal: Bitcoin address directory #bitcoin

bitcointalk.org 21 Jul '12, 8pm

Say you want to send bitcoins to someone on a forum like reddit, Hacker News, Facebook, or by e-mail, and they don't have ...

rake db:test:prepare - Ruby Forum:

ruby-forum.com 20 Jul '12, 3pm

I'm having fun with a legacy DB (SQL Server), and in the process found some code in rails/lib/tasks/databases.rake which f...

Status: Resolved / ONLINE MT @bitcoinstatus: Th...

bitcointalk.org 31 Jul '12, 7am

General discussion about the Bitcoin ecosystem that doesn't fit better elsewhere. News, the Bitcoin community, innovations...

Checkout Coinbase - the simplest way to get sta...

coinbase.com 25 Jul '12, 1am

Instant Payments Payments arrive at the speed of an email (just a few seconds) and are confirmed within the hour. No more ...

717 Trading: You pay for what you get!: D100 - Bitter Sweet Durian It's been a rather fruitful (literally) Duria...

717 Trading: You pay for what you get!: D100 - ...

ieatishootipost.sg 24 Jul '12, 2am

It's been a rather fruitful (literally) Durian Season for me as I managed to expand the list of Durian cultivars as well a...

Can we get an ETA on when trading will resume? ...

bitcointalk.org 21 Jul '12, 7am

ATM all trading is frozen, and it happened during a huge rally i guess the order was too big to fill or something. I just ...

Get current. - - Nike Air Current "BLACK/ VOLTA...

sneakerhead.com 16 Jul '12, 7pm

The Nike Air Current is back for the first time since its original debut in the 90s. Despite an elastic forefoot strap and...

6 Reasons You Should Stay With Your Current Sma...

searchenginewatch.com 19 Jul '12, 9am

It's tempting to change vendors when your small business SEO has seemed to stall. But the hidden costs of vendor hopping a...