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

Constant Summary collapse

DEFAULT_OPTIONS =
{
  account_control_ignores_summary_amounts: false,
  num_account_summary_continuation_records: 0,
  continuations_slash_delimit_end_of_line_only: false,
}.freeze

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, options = {}) ⇒ BaiFile

Parse a Bai2 data buffer:

f = BaiFile.new(bai2_data)


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

def initialize(raw, options = {})
  @raw = raw
  @groups = []
  @options = DEFAULT_OPTIONS.merge(options)
  parse(raw, options)
end

Instance Attribute Details

#groupsObject (readonly)

The groups contained within this file.



43
44
45
# File 'lib/bai2.rb', line 43

def groups
  @groups
end

#rawObject (readonly)

This is the raw data. Probably not super important.



40
41
42
# File 'lib/bai2.rb', line 40

def raw
  @raw
end

Class Method Details

.parse(path, options = {}) ⇒ Object

Parse a file on disk:

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


23
24
25
# File 'lib/bai2.rb', line 23

def self.parse(path, options = {})
  self.new(File.read(path), options)
end

Instance Method Details

#file_creation_datetimeObject



55
56
57
# File 'lib/bai2.rb', line 55

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