Search code examples
rubycocoarubymotionmacruby

Use simple & useful ruby methods such as basename in RubyMotion


RubyMotion does not support

require 

in code (only in RakeFile).

Is there a way to use useful classes built into Ruby but not into RubyMotion ? For instance, I'd like to be able to do a

name=Pathname.new("/path/to/some/file").basename

rather than look for Cocoa equivalent


Solution

  • Pathname is one of those pieces of the Ruby Standard Library that are not available in RubyMotion.

    You can try with MotionBundler, but I personally haven't been very lucky with that.

    I'd suggest to use the Cocoa equivalent. Something like:

    name = "/path/to/some/file".lastPathComponent
    

    Not that bad, anyway.