module NWN::Gff::Handler
A namesoace for all Gff
file format handlers.
Public Class Methods
register(name, fileFormatRegexp, klass, reads = true, writes = true)
click to toggle source
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.
# File lib/nwn/gff.rb, line 32 def self.register name, fileFormatRegexp, klass, reads = true, writes = true raise ArgumentError, "Handler for #{name.inspect} already registered." if NWN::Gff::InputFormats[name.to_sym] || NWN::Gff::OutputFormats[name.to_sym] NWN::Gff::InputFormats[name.to_sym] = klass if reads NWN::Gff::OutputFormats[name.to_sym] = klass if writes NWN::Gff::FileFormatGuesses[name.to_sym] = fileFormatRegexp end