README

Path: README
Last Update: Fri Mar 23 01:23:18 +0100 2007

Ruby-EET — Ruby bindings for EET

Ruby-EET allows you to read and write EET files from Ruby code. Support for Ruby object serialization to EDD (EET Data Descriptor) format is given.

Ruby-EET is maintained by:

Tilman Sauerbeck (tilman at code-monkey de)

License

Ruby-EET is available under an MIT-style license.

Copyright (c) 2005-2007 Tilman Sauerbeck (tilman at code-monkey de)

Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:

The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.

THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.

Download

The latest version of Ruby-EET can be found at code-monkey.de/pages/ruby-eet

Online documentation is available at docs.code-monkey.de/ruby-eet

Dependencies

Ruby-EET depends on Rake 0.5.0 or greater and EET.

Installation

Run "rake install" to install Ruby-EET.

Usage

Basics

Each entry in an EET file consists of an unique key and the data that‘s associated with that key.

First, you have to open an EET file by calling Eet::File.open.

Now, you can store arbitrary data in the EET file with Eet::File#write. To read the data from the EET file, use Eet::File#read.

If you want to store/retrieve image data, see Eet::File#read_image and Eet::File#write_image.

Serializing objects

Ruby-EET also supports the serialization of objects which uses the same format as the C API uses for its EET data descriptors. At the time of this writing, deserialization, i.e. read support, isn‘t implemented yet, though.

Example:

  class Foo
    def initialize
      @str = "bar"
      @int = 1024
    end
  end

Now, Foo.new.to_eet will serialize the object into EET format. All of the objects instance variables will be serialized, and the class name will be used as the tag.

To override the tag, you just need to implement Foo#to_eet_name:

  class Foo
    def to_eet_name
      "Blah"
    end
  end

To control what information is stored for an object, override the method to_eet_properties.

to_eet_properties returns a hash containing keys that are the names of the stored properties. Each hash value is an array that contains the value to store at least. Optionally, it can also contain a type specifier to enforce specific encoding.

Type specifiers

For fixnums and bignums, the valid type specifiers are :char, :short, :long_long which enforce encoding as 1 byte, 2 byte or 8 byte value respectively. The default is to encode the value as a 4 byte value.

For floats, the valid type specifier is :double, which enforces encoding as an 8 byte value. The default is to encode the value as a 4 byte value.

[Validate]