Class: Bai2::BaiFile

Inherits:
Object
  • Object
show all
Extended by:
AttrReaderFromIvarHash
Defined in:
lib/bai2.rb,
lib/bai2/integrity.rb

Overview

This class is the main wrapper around a Bai2 file.

Defined Under Namespace

Classes: Account, Group, IntegrityError, Transaction

Instance Attribute Summary collapse

Class Method Summary collapse

Instance Method Summary collapse

Methods included from AttrReaderFromIvarHash

attr_reader_from_ivar_hash

Constructor Details

#initialize(raw) ⇒ BaiFile

Parse a Bai2 data buffer:

f = BaiFile.new(bai2_data)


27
28
29
30
31
# File 'lib/bai2.rb', line 27

def initialize(raw)
  @raw = raw
  @groups = []
  parse(raw)
end

Instance Attribute Details

#groupsObject (readonly)

The groups contained within this file.



37
38
39
# File 'lib/bai2.rb', line 37

def groups
  @groups
end

#rawObject (readonly)

This is the raw data. Probably not super important.



34
35
36
# File 'lib/bai2.rb', line 34

def raw
  @raw
end

Class Method Details

.parse(path) ⇒ Object

Parse a file on disk:

f = BaiFile.parse('myfile.bai2')


18
19
20
# File 'lib/bai2.rb', line 18

def self.parse(path)
  self.new(File.read(path))
end

Instance Method Details

#file_creation_datetimeObject



49
50
51
# File 'lib/bai2.rb', line 49

def file_creation_datetime
  @header[:file_creation_date] + @header[:file_creation_time]
end