r-classpathify

Translates Module X; class Y; lines in a ruby file to X::Y for STDOUT

Ruby geeks frequently need to refer to a class by its fully qualified name. But there’s nowhere to get that name in the appropriate format.

For example:

module Foo
  module Bar
   class Baz
     ...
   end
  end
end

The developer would need to refer to that as Foo::Bar::Baz in their code.

So, point r-classpathify at the file in question and it’ll read that in, and generate the appropriate single-line version for you.

Integrate this with your editor and you can get it to just tell you the “classpathified” name of the current file. How to do that is an exercise for the reader.

Usage

USAGE: r-classpathify <path/to/ruby/file>
       Converts all the module X, module Y, class Z lines
       in a Ruby file and converts them to
       X::Y::Z and prints it to STDOUT

Metadata:

Tags:

  • ruby