Class: Palm::WabaDB
Overview
SuperWaba supports Palm PDB files, but handles them a little awkwardly. Each of the file’s different record types must be passed in when constructing a new WabaDB so we know what record types are available.
Constant Summary
Constants inherited from PDB
PDB::ATTRIBUTE_CODES, PDB::HEADER_LENGTH, PDB::INDEX_RECORD_LENGTH, PDB::INDEX_RESOURCE_LENGTH, PDB::RECORD_INDEX_HEADER_LEN
Instance Attribute Summary
Attributes inherited from PDB
#attributes, #backed_up_at, #created_at, #creator, #data, #modified_at, #modnum, #name, #type, #unique_id_seed, #version
Instance Method Summary collapse
-
#initialize(*record_classes) ⇒ WabaDB
constructor
Create a new WabaDB with
record_classes
as the available types of records. - #pack_entry(entry) ⇒ Object
- #unpack_entry(data) ⇒ Object
Methods inherited from PDB
#load, #load_file, #resource?, #write, #write_file
Constructor Details
#initialize(*record_classes) ⇒ WabaDB
Create a new WabaDB with record_classes
as the available types of records. See Palm::WabaRecord for more information.
8 9 10 11 12 13 14 15 16 |
# File 'lib/palm/waba_db.rb', line 8 def initialize(*record_classes) super() if record_classes.empty? raise ArgumentError.new('At least one WabaRecord class must be provided.') end @record_index = {} record_classes.each{|c| @record_index[c.class_id] = c } @last_class = record_classes.first end |
Instance Method Details
#pack_entry(entry) ⇒ Object
25 26 27 28 29 30 31 |
# File 'lib/palm/waba_db.rb', line 25 def pack_entry(entry) data = "" s = WabaStringIO.new(data) s.write_byte(entry.class_id) entry.write(s) data end |
#unpack_entry(data) ⇒ Object
18 19 20 21 22 23 |
# File 'lib/palm/waba_db.rb', line 18 def unpack_entry(data) s = WabaStringIO.new(data) class_id = s.get_byte c = class_for(class_id) c.new.read(s) end |