Module NWN::Gff

  1. lib/nwn/gff.rb

Methods

public class

  1. guess_file_format
  2. read
  3. write

Constants

Types = { 0 => :byte, 1 => :char, 2 => :word, 3 => :short, 4 => :dword, 5 => :int, 6 => :dword64, 7 => :int64, 8 => :float, 9 => :double, 10 => :cexostr, 11 => :resref, 12 => :cexolocstr, 13 => :void, 14 => :struct, 15 => :list, }.freeze   This hash lists all possible NWN::Gff::Field types.
Formats = { :byte => "Cxxx", :char => "Cxxx", :word => 'Sxx', :short => 'sxx', :dword => 'I', :int => 'i', :dword64 => 'II', :int64 => 'q', :float => 'f', :double => 'd', }.freeze
InputFormats = {}
OutputFormats = {}
FileFormatGuesses = {}

Public class methods

guess_file_format (filename)
[show source]
# File lib/nwn/gff.rb, line 123
    def self.guess_file_format(filename)
      extension = File.extname(filename.downcase)[1..-1]
      matches = FileFormatGuesses.select {|fmt,rx| extension =~ rx }
      if matches.size == 1
        matches[0][0]
      else
        nil
      end
    end
read (io, format)
[show source]
# File lib/nwn/gff.rb, line 133
    def self.read(io, format)
      if InputFormats[format]
        InputFormats[format].load(io)
      else
        raise NotImplementedError, "Don't know how to read #{format}."
      end
    end
write (io, format, data)
[show source]
# File lib/nwn/gff.rb, line 141
    def self.write(io, format, data)
      if OutputFormats[format]
        OutputFormats[format].dump(data, io)
      else
        raise NotImplementedError, "Don't know how to write #{format}."
      end
    end