Ruby Singleton Class

Ruby Singleton Class

Postby kwalkerman » Tue Jul 27, 2010 8:14 pm

Hi,

I'm trying to reference the ruby Singleton Class... but when I require singleton, I get the error: "No such file to load -- singelton"

I thought this was one of the Ruby native classes? Any idea why SU can't find it? Is there any way to restore the file and/or the source code so that I can reference it?

Thanks,

--
Karen
0

kwalkerman 
 

Re: Ruby Singleton Class

Postby kwalkerman » Tue Jul 27, 2010 8:36 pm

Ok, found a copy here: http://sketchuptips.blogspot.com/2008/0 ... point.html

if anyone needs it in the future.

--
Karen
0

kwalkerman 
 

Re: Ruby Singleton Class

Postby Dan Rathbun » Tue Jul 27, 2010 10:50 pm

kwalkerman wrote:I thought this was one of the Ruby native classes?

There are 2 catagories of Ruby Base Classes:

  1. Standard Included
    • These are loaded along with the Ruby Interpreter. (They are bundled inside the DLL.)
  2. Extended Library
    • These must be loaded when needed by using the require('libfilename') method.

kwalkerman wrote:Any idea why SU can't find it?

Because Windows Sketchup does not come with a full Ruby Installation. (Some platforms: Linux, Apple OSX, etc. come "out-of-the-box" with a full Ruby Installation, but this is the OS OEM's doing, and not Google's.)

In either case Sketchup is not preset to find the Standard Ruby Library folders. You would need to run a script like my example:
See: [code] Ruby LOAD PATHs script for (Win32)

kwalkerman wrote:Is there any way to restore the file and/or the source code so that I can reference it?

On Windows you need to go get the Windows One-Click Installer to install Ruby on your system.
See the section: Ruby on Windows on the RubyLang.org Downloads page:
http://www.ruby-lang.org/en/downloads/

I have not tried v.1.8.7 with Sketchup yet, I usually recommend the latest v.1.8.6

After install... you'd need to backup the 'msvcrt-ruby18.dll' file in the Sketchup program folder (or rename it to: 'msvcrt-ruby180_p10.dll' as that is the actual version and patch level that ships with Win32 Sketchup.)

Then COPY (not move,) the interpreter dll from your new install's bin folder (usually C:/ruby{ver}/bin/) to the Sketchup program folder, renaming the copy to: 'msvcrt-ruby18.dll' (The Ruby guys have started putting all 3 version numbers into the filenames, so you might see it named: 'msvcrt-ruby187.dll'. Just be sure to leave it named as is, in the real Ruby bin folder; But Sketchup is hard-coded to load an exact interpreter dll filename.)

The purpose / idea here is to be using the same version Library files as the interpreter your running.
0
Last edited by Dan Rathbun on Sat Jul 31, 2010 1:38 am, edited 2 times in total.
    I'm not here much anymore. But a PM will fire email notifications.
    User avatar
    Dan Rathbun 
    PluginStore Author
    PluginStore Author
     

    Re: Ruby Singleton Class

    Postby Jim » Fri Jul 30, 2010 4:50 pm

    kwalkerman wrote:Ok, found a copy here: http://sketchuptips.blogspot.com/2008/0 ... point.html

    if anyone needs it in the future.

    --
    Karen


    That file is from the Ruby language installation version 1.8.6.

    I used it because it is the "Ruby Way" of implementing a singleton class, but it turned out I didn't really need all that. It's not hard to make any class behave like a singleton class without including singleton.rb.

    What is it you are doing? A single instance of a WebDialog, maybe?
    0
    Hi

    Jim 
    Global Moderator
     

    SketchUcation One-Liner Adverts

    by Ad Machine » 5 minutes ago



    Ad Machine 
    Robot
     



     

    Return to Developers' Forum

    Who is online

    Users browsing this forum: No registered users and 17 guests

    Visit our sponsors: