SketchUp / sketchup-stl

A SketchUp Ruby Extension that adds STL (STereoLithography) file format import and export.
http://extensions.sketchup.com/content/sketchup-stl
MIT License
248 stars 68 forks source link

Importer Subclass and inheriting constants #62

Closed DanRathbun closed 11 years ago

DanRathbun commented 11 years ago

importer.rb:line 11

CommunityExtensions::STL::Importer should be subclass of Sketchup::Importer

Allows inheritance of common functionality, etc.

For instance, the Sketchup::Importer superclass has ALREADY defined status constants, that can be inherited, viz (at the console): Sketchup::Importer.constants.sort returns:

["ImportCanceled", "ImportFail", "ImportFileNotFound",
 "ImportSuccess", "ImporterNotFound"]

It is generally best practice to use these API defined constants for future API compatibility, rather than defining custom constants that reference discrete integers.

IF you MUST (because you do not like the the fact that the superclass' constants are in module/class identifier style, instead of ALL_CAPS constant style,) then you can do:

      IMPORT_SUCCESS                        = ImportSuccess
      IMPORT_FAILED                         = ImportFail
      IMPORT_CANCELLED                      = ImportCanceled
      IMPORT_FILE_NOT_FOUND                 = ImportFileNotFound
      IMPORT_SKETCHUP_VERSION_NOT_SUPPORTED = 5

... **provided that you sublcass Sketchup::Importer

There is a API question. What is Sketchup::Importer::ImporterNotFound which equals 3 ??

:)

thomthom commented 11 years ago

Ah, another set of undocumented constants. Didn't realise the Sketchup::Importer had any content to it - or even that it was defined (like the Tool class).

thomthom commented 11 years ago

I'm marking this as fixed.

( @jimfoltz if you in the commit writes in the format of "fixes #62" it will automatically close the issue when merged.)