sketchucation logo sketchucation
    • Login
    ℹ️ Licensed Extensions | FredoBatch, ElevationProfile, FredoSketch, LayOps, MatSim and Pic2Shape will require license from Sept 1st More Info

    Ruby Singleton Class

    Scheduled Pinned Locked Moved Developers' Forum
    4 Posts 3 Posters 1.7k Views 3 Watching
    Loading More Posts
    • Oldest to Newest
    • Newest to Oldest
    • Most Votes
    Reply
    • Reply as topic
    Log in to reply
    This topic has been deleted. Only users with topic management privileges can see it.
    • K Offline
      kwalkerman
      last edited by

      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

      1 Reply Last reply Reply Quote 0
      • K Offline
        kwalkerman
        last edited by

        Ok, found a copy here: http://sketchuptips.blogspot.com/2008/03/plugin-auto-centerpoint.html

        if anyone needs it in the future.

        --
        Karen

        1 Reply Last reply Reply Quote 0
        • J Offline
          Jim
          last edited by

          @kwalkerman said:

          Ok, found a copy here: http://sketchuptips.blogspot.com/2008/03/plugin-auto-centerpoint.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?

          Hi

          1 Reply Last reply Reply Quote 0
          • Dan RathbunD Offline
            Dan Rathbun
            last edited by

            @kwalkerman said:

            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.)
            1. 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.

            I'm not here much anymore.

            1 Reply Last reply Reply Quote 0
            • 1 / 1
            • First post
              Last post
            Buy SketchPlus
            Buy SUbD
            Buy WrapR
            Buy eBook
            Buy Modelur
            Buy Vertex Tools
            Buy SketchCuisine
            Buy FormFonts

            Advertisement