Module: NWN::Gff
Defined Under Namespace
Modules: Cexolocstr, CexolocstrValue, Field, Handler, List, Scripting, Struct Classes: GffError, GffPathInvalidError, GffTypeError, Reader, Writer
Constant Summary collapse
- Types =
This hash lists all possible NWN::Gff::Field 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
- ComplexTypes =
:stopdoc: Used internally to figure out if a field is stored directly or by reference.
[6, 7, 9, 10, 11, 12, 13, 14, 15].freeze
- SimpleTypes =
(Types.keys - ComplexTypes)
- Formats =
:startdoc:
{ :byte => "Cxxx", :char => "Cxxx", :word => 'Sxx', :short => 'sxx', :dword => 'I', :int => 'i', :dword64 => 'II', :int64 => 'q', :float => 'f', :double => 'd', }.freeze
- InputFormats =
{}
- OutputFormats =
{}
- FileFormatGuesses =
{}
Class Method Summary collapse
Class Method Details
.guess_file_format(filename) ⇒ Object
123 124 125 126 127 128 129 130 131 |
# 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.keys[0] else nil end end |
.read(io, format) ⇒ Object
133 134 135 136 137 138 139 |
# 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) ⇒ Object
141 142 143 144 145 146 147 |
# 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 |