Ruby Singleton Class
-
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 -
Ok, found a copy here: http://sketchuptips.blogspot.com/2008/03/plugin-auto-centerpoint.html
if anyone needs it in the future.
--
Karen -
@kwalkerman said:
Ok, found a copy here: http://sketchuptips.blogspot.com/2008/03/plugin-auto-centerpoint.html
if anyone needs it in the future.
--
KarenThat 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?
-
@kwalkerman said:
I thought this was one of the Ruby native classes?
There are 2 catagories of Ruby Base Classes:
- Standard Included
- These are loaded along with the Ruby Interpreter. (They are bundled inside the DLL.)
- Extended Library
- These must be loaded when needed by using the require('libfilename') method.
@kwalkerman said:
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 said:
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.
Advertisement