Class: AAlib::SaveData

Inherits:
CPtr show all
Defined in:
lib/aalib.rb

Overview

Encapsulation of data required to save a file to disk.

Constant Summary collapse

TYPE =

:nodoc:

'SPP'
NAMES =

:nodoc:

[:name, :format, :file]

Instance Method Summary collapse

Methods inherited from CPtr

#[], #[]=, #inspect, new_ptr

Methods included from ArgumentChecks

included

Methods inherited from DL::PtrData

#string?

Constructor Details

#initialize(name, format, formatflags = 0) ⇒ SaveData

Initializes a new SaveData to save to file name with SaveFormat format. Passing a string format uses the format returned by AAlib::SaveFormat.find. See AAlib::SaveFormat for options set with flags; multiple flags should be logically OR’ed.

The AA-lib docs claim that file extensions are added automatically, but this appears to be false.



1069
1070
1071
1072
1073
1074
1075
1076
1077
1078
1079
1080
1081
# File 'lib/aalib.rb', line 1069

def initialize(name, format, formatflags=0)
  super()

  self.name = name

  if format.kind_of? AAlib::SaveFormat
    self.format = format
  else
    self.format = AAlib::SaveFormat.find(format)
  end

  self.format.flags = formatflags
end

Instance Method Details

#formatObject

Returns the AAlib::SaveFormat that will be used for saving



1084
1085
1086
# File 'lib/aalib.rb', line 1084

def format
  SaveFormat.new(self[:format])
end

#nameObject

Returns the file name that will be used for saving.



1057
# File 'lib/aalib.rb', line 1057

def name; end