RUBYLIB and shared libraries

Discussion in 'Ruby' started by Alpha Blue, Feb 2, 2010.

  1. Alpha Blue

    Alpha Blue Guest

    Hi everyone,

    I'm setting up my RUBYLIB variables for use with custom libraries I've
    created. I have the following working properly:

    C:/lib/wxruby/lib [this points to the custom library path I have set]

    Everything is verified with ruby -e "puts $:" ..

    The first module I created is a module called public_instance_methods.rb

    Location: C:/lib/wxruby/lib/public_instance_methods.rb

    module PublicInstanceMethods

    # This method sets the default icon for the given window or frame
    def set_icon_file(file)
    icon_file = File.join(File.dirname(__FILE__),"..","icons",file)
    set_icon Wx::Icon.new(icon_file, Wx::BITMAP_TYPE_ICO)
    end

    end

    My default working project directory is:

    E:\project\lib\
    "" \core
    "" \icons
    "" \images

    In E:\project\lib\core\main.rb I have..

    require 'public_instance_methods'
    include PublicInstanceMethods

    class GuiMain < XrcFrameMain
    def initialize
    super()

    set_icon_file("test.ico")

    end
    end

    Which results into an error saying:

    Icon file does not exist:
    C:/lib/wxruby/lib/../icons/kirin.ico (ArgumentError)

    .. which means that it's looking in the lib directory of the included
    module and not the working directory of the application. How should I
    set this method up so that it includes the right path to the ico file?
    --
    Posted via http://www.ruby-forum.com/.
     
    Alpha Blue, Feb 2, 2010
    #1
    1. Advertisements

  2. Alpha Blue

    Alpha Blue Guest

    Jason Perry wrote:
    > You can use RAILS_ROOT but I'm sure there is a better way.


    wha??

    This isn't a rails discussion topic and has nothing to do with rails.
    Someone else?
    --
    Posted via http://www.ruby-forum.com/.
     
    Alpha Blue, Feb 2, 2010
    #2
    1. Advertisements

  3. Alpha Blue

    Alpha Blue Guest

    Jason Perry wrote:
    > Sorry, man.
    >
    > If you want to define the root of your application you could always set
    > a
    > global variable in your main.rb or set a global variable.


    Thanks Jason. That's what I needed:

    main.rb

    $file_path = __FILE__

    set_icon_file($file_path,"..","icons","test.ico")

    .. then in my custom lib directory for PublicInstanceMethods I have:

    # This method sets the default icon for the given window or frame
    def set_icon_file(path, *file)
    icon_file = File.join(File.dirname(path), file)
    set_icon Wx::Icon.new(icon_file, Wx::BITMAP_TYPE_ICO)
    end

    .. and now everything works fine. If there is a better way of doing
    this with regard to use of custom lib files, please let me know.

    Thanks.

    --
    Posted via http://www.ruby-forum.com/.
     
    Alpha Blue, Feb 2, 2010
    #3
    1. Advertisements

Want to reply to this thread or ask your own question?

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. Dave Neary

    JVM and shared libraries

    Dave Neary, Jun 9, 2004, in forum: Java
    Replies:
    13
    Views:
    1,585
  2. Steve

    STL and shared libraries

    Steve, Nov 12, 2005, in forum: C++
    Replies:
    7
    Views:
    680
    Valentin Samko
    Nov 12, 2005
  3. barcaroller
    Replies:
    1
    Views:
    437
    Ian Collins
    Jun 12, 2007
  4. Replies:
    0
    Views:
    349
  5. Replies:
    0
    Views:
    872
  6. Chris Spiegel

    RubyGems and $RUBYLIB

    Chris Spiegel, Feb 28, 2005, in forum: Ruby
    Replies:
    0
    Views:
    234
    Chris Spiegel
    Feb 28, 2005
  7. Bothari
    Replies:
    0
    Views:
    194
    Bothari
    Aug 19, 2006
  8. gdb and shared libraries issue

    , Oct 8, 2012, in forum: C Programming
    Replies:
    11
    Views:
    638
Loading...