Plugin Design - Import/Export


Description Attributes Methods See Also

Description

Draco implements custom, non-native file loading plugins via the import/export plugin class.  The class, Plugin::IOPluginSkeleton, is designed to simplify the process of loading data into a Draco worksheet and saving Draco numeric data into other file formats.

Available Attributes

Import/Export plugins have a number of specialized attributes beyond the normal option access. These additional attributes are described below:
Attribute Read/Write (Unenforced) Expected Type Description
@data Write Matrix When loading data, the @data attribute should be assigned a matrix of numeric data to be loaded into the worksheet
@file Read IO A Ruby IO object opened for reading from or writing to depending on the load/save operation. Only available if @streams is true
@filename Read String The filename selected by the user
@model Read Model::Data An object providing access to the current data model of the current worksheet. Normally only used during export operations
@streams Read/Write Boolean Flag indicating whether the user-selected file should automatically opened as a Ruby IO object. If true, the @file attribute will contain a valid IO object. If false, the @file attribute will be nil.

Necessary Methods

Unlike other regression types, Import/Export plugins should implement additional methods. The primary methods that must be implemented are load and save. The four methods are described below:
Method Mandatory? Description
load Yes This method will perform primary data reading during an import operation. This method is also expected to assign a value to the @load attribute before exiting.
preload No This method is called after the user selects a filename but prior to presenting options to the user. This method can configure options based on preliminary file information, including reading from the file.
presave No This method, similar to preload, is called after a filename is selected, but before presenting options to the user. Plugin options can be configured at this step.
save Yes When performing a data export, this method should do the bulk of the data writing. The current worksheet is accessible via the @model attribute.

See Also

Plugin Design - Necessities
Plugin System Technical
Copyright © 2009 Approximatrix, LLC
Text licensed under the Creative Commons Attribution-Share Alike 3.0 License
DracoTM and the Approximatrix logo are trademarks of Approximatrix, LLC
Other trademarks are property of their respective owners