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
123:     def self.guess_file_format(filename)
124:       extension = File.extname(filename.downcase)[1..-1]
125:       matches = FileFormatGuesses.select {|fmt,rx| extension =~ rx }
126:       if matches.size == 1
127:         matches[0][0]
128:       else
129:         nil
130:       end
131:     end
read (io, format)
[show source]
     # File lib/nwn/gff.rb, line 133
133:     def self.read(io, format)
134:       if InputFormats[format]
135:         InputFormats[format].load(io)
136:       else
137:         raise NotImplementedError, "Don't know how to read #{format}."
138:       end
139:     end
write (io, format, data)
[show source]
     # File lib/nwn/gff.rb, line 141
141:     def self.write(io, format, data)
142:       if OutputFormats[format]
143:         OutputFormats[format].dump(data, io)
144:       else
145:         raise NotImplementedError, "Don't know how to write #{format}."
146:       end
147:     end