Account Options

  1. Sign in
The old Google Groups will be going away soon, but your browser is incompatible with the new version.
Google Groups Home
« Groups Home
Discussions > SketchUp Ruby API > Attention Ruby Developers
There are currently too many topics in this group that display first. To make this topic appear first, remove this option from another topic.
There was an error processing your request. Please try again.
flag
  4 messages - Collapse all  -  Translate all to Translated (View all originals)
The group you are posting to is a Usenet group. Messages posted to this group will make your email address visible to anyone on the Internet.
Your reply message has not been sent.
Your post was successful
 
From:
To:
Cc:
Followup To:
Add Cc | Add Followup-to | Edit Subject
Subject:
Validation:
For verification purposes please type the characters you see in the picture below or the numbers you hear by clicking the accessibility icon. Listen and type the numbers you hear
 
SketchUp Guide Jody Google employee  
View profile  
 More options Feb 21 2008, 6:16 pm
From: SketchUp Guide Jody <sketchup-guide-jo...@google.com>
Date: Thu, 21 Feb 2008 15:16:39 -0800 (PST)
Local: Thurs, Feb 21 2008 6:16 pm
Subject: Attention Ruby Developers
Did you know that we have a resource for Ruby developers in addition
to these discussions? You can view the SketchUp Ruby API documentation
in its own Google Group at the link below:

http://groups.google.com/group/SketchUp-Plugins-Dev

This is a resource for advanced users of Ruby and isn't intended for
simple installation questions or suggestions for others to implement.
Please feel free to visit this resource if you're actively developing
for SketchUp.


 
You must Sign in before you can post messages.
To post a message you must first join this group.
Please update your nickname on the subscription settings page before posting.
You do not have the permission required to post.
Todd Burch - Katy, Texas  
View profile  
 More options Feb 21 2008, 10:00 pm
From: "Todd Burch - Katy, Texas" <mr.todd.bu...@gmail.com>
Date: Thu, 21 Feb 2008 19:00:26 -0800 (PST)
Local: Thurs, Feb 21 2008 10:00 pm
Subject: Re: Attention Ruby Developers
Thanks Jody.

And to add to this, see this thread to learn how you can help update
the doc with corrections, better examples, and other improvements.

http://www.sketchucation.com/forums/scf/viewtopic.php?f=57&t=5863

You don't have to register at Sketchucation if you don't want - you
can post your improvement suggestions here too.

Todd

On Feb 21, 5:16 pm, SketchUp Guide Jody <sketchup-guide-


 
You must Sign in before you can post messages.
To post a message you must first join this group.
Please update your nickname on the subscription settings page before posting.
You do not have the permission required to post.
Dan Rathbun  
View profile  
 More options Feb 5, 6:44 am
From: Dan Rathbun <danz...@earthlink.net>
Date: Sun, 5 Feb 2012 03:44:24 -0800 (PST)
Local: Sun, Feb 5 2012 6:44 am
Subject: Re: Attention Ruby Developers
 
You must Sign in before you can post messages.
To post a message you must first join this group.
Please update your nickname on the subscription settings page before posting.
You do not have the permission required to post.
Dan Rathbun  
View profile  
 More options Feb 8, 9:53 am
From: Dan Rathbun <danzoi...@gmail.com>
Date: Wed, 8 Feb 2012 06:53:32 -0800 (PST)
Local: Wed, Feb 8 2012 9:53 am
Subject: Re: Attention Ruby Developers

FAQ: How can I detect if my plugin is running on the Mac vs. PC ?
from: Frequently Asked Questions (FAQ)<http://developers.google.com/sketchup/docs/faq>

The answer (as of this posting date,) has a VERY POOR example. Do not use it
.
------------------------------

DO

It is BEST to create Boolean constants for comparison:
CODE: SELECT ALL<http://forums.sketchucation.com/viewtopic.php?f=180&t=34631#>

   1. MAC = ( Object::RUBY_PLATFORM =~ /(darwin)/i ? true : false ) unless
   defined?(MAC)
   2. WIN = ( not MAC ) unless defined?(WIN)
   3. OSX = MAC unless defined?(OSX)
   4. PC = WIN unless defined?(PC)

   - You can put these outside your author module (namespace,) so they are
   global constants
   - Or within anyone of your namespaces (submodules and/or classes,) so
   they are local
   - If you put these statements, within YOUR toplevel "Author" module,
   then the platform constants, will be accessible, to all of your nested
   modules and classes.

Then you can just have an if statement like:
CODE: SELECT ALL<http://forums.sketchucation.com/viewtopic.php?f=180&t=34631#>

   1. if MAC
   2.   dialog.show_modal()
   3. elsif WIN
   4.   dialog.show()
   5. else
   6.   UI.messagebox('Unsupported Platform for UI::WebDialog class.')
   7. end

or:CODE: SELECT ALL<http://forums.sketchucation.com/viewtopic.php?f=180&t=34631#>

   1. if WIN
   2.   require('WIN32OLE')
   3. else
   4.   puts("Win32OLE.so is a Windows only utility!", MB_OK)
   5. end

------------------------------

DO NOT

CODE: SELECT ALL<http://forums.sketchucation.com/viewtopic.php?f=180&t=34631#>

   1. PLATFORM = (Object::RUBY_PLATFORM =~ /mswin/i) ? :windows : ((Object::
   RUBY_PLATFORM =~ /darwin/i) ? :mac : :other)

The example overwrites (reassigns,) the value of the standard (although
deprecated,) Ruby constant PLATFORM. The example should use another
constant name, perhaps PLAT_SYM.

Note also that the example creates interned String values that will later
be used for comparison.
Ruby is extremely SLOW at String comparison.
Observe:
PLAT_SYM.to_s == "windows"
Is much slower than testing a boolean constant. Reason is that Ruby must
create a new String instance object, whenever it encounters a literal
quoted text in your code. (In this example, Ruby must create TWO new String instance
objects, one on each side of the ==operator. They are abandoned, aka unreferenced,
after the line is evaluated. Ruby garbage collection will clean them up
eventually. Sooner if the statement was within a method.)

It also makes no sense, to assign Symbol constants, and then convert them
to a String during a boolean test. It is better (if you absolutly need to
use a Symbol,) to do Symbol comparison, like:
PLAT_SYM == :windows

~


 
You must Sign in before you can post messages.
To post a message you must first join this group.
Please update your nickname on the subscription settings page before posting.
You do not have the permission required to post.
End of messages
« Back to Discussions « Newer topic