Module NWN::Gff::Handler

  1. lib/nwn/gff.rb

A namesoace for all Gff file format handlers.

Methods

public class

  1. register

Public class methods

register (name, fileFormatRegexp, klass, reads = true, writes = true)

Registers a new format handler that can deal with file formats for nwn-lib gff handling.

name
The name of this format as a symbol. Must be unique.
fileFormatRegexp
A regular expression matching file extensions for auto-detection.
klass
A object that responds to load(io) and dump(gff,io). load(io) reads from io and always returns a NWN::Gff::Struct describing a root struct, dump(gff, io) dumps the gff root struct in the handlers format to io and returns the number of bytes written.
reads
Boolean, indicates if this handler can read it’s format and return gff data.
writes
Boolean, indicates if this handler can emit gff data in it’s format.
[show source]
    # File lib/nwn/gff.rb, line 32
32:       def self.register name, fileFormatRegexp, klass, reads = true, writes = true
33:         raise ArgumentError, "Handler for #{name.inspect} already registered." if
34:           NWN::Gff::InputFormats[name.to_sym] || NWN::Gff::OutputFormats[name.to_sym]
35:         NWN::Gff::InputFormats[name.to_sym] = klass if reads
36:         NWN::Gff::OutputFormats[name.to_sym] = klass if writes
37:         NWN::Gff::FileFormatGuesses[name.to_sym] = fileFormatRegexp
38:       end