Class: WenlinDbScanner::DbRecord

Inherits:
Object
  • Object
show all
Defined in:
lib/wenlin_db_scanner/db_record.rb

Overview

Wraps record data returned by WenlinDbScanner::Db methods.

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(offset, tag, size, binary, data) ⇒ DbRecord

Used by the WenlinDbScanner::Db methods.



27
28
29
30
31
32
33
34
35
36
37
38
39
# File 'lib/wenlin_db_scanner/db_record.rb', line 27

def initialize(offset, tag, size, binary, data)
  @offset = offset
  @tag = tag
  @size = size
  @binary = binary
  if @binary
    @data = data
    @text = nil
  else
    @text = data
    @data = nil
  end
end

Instance Attribute Details

#binaryBoolean (readonly) Also known as: binary?

Returns true if the record has non-text data, such as pictures.

Returns:

  • (Boolean)

    true if the record has non-text data, such as pictures



6
7
8
# File 'lib/wenlin_db_scanner/db_record.rb', line 6

def binary
  @binary
end

#dataString? (readonly)

Returns ASCII-8BIT encoded binary data; nil for text records.

Returns:

  • (String, nil)

    ASCII-8BIT encoded binary data; nil for text records



13
14
15
# File 'lib/wenlin_db_scanner/db_record.rb', line 13

def data
  @data
end

#offsetObject (readonly)

The record’s position in the database.



24
25
26
# File 'lib/wenlin_db_scanner/db_record.rb', line 24

def offset
  @offset
end

#sizeObject (readonly)

Raw data size, in bytes.

For text records, this is the size of the compressed data.



21
22
23
# File 'lib/wenlin_db_scanner/db_record.rb', line 21

def size
  @size
end

#tagFixnum (readonly)

Returns the record’s tag byte (a number in 0…256).

Returns:

  • (Fixnum)

    the record’s tag byte (a number in 0…256)



16
17
18
# File 'lib/wenlin_db_scanner/db_record.rb', line 16

def tag
  @tag
end

#textString? (readonly)

Returns UTF-8 encoded text data; nil for binary records.

Returns:

  • (String, nil)

    UTF-8 encoded text data; nil for binary records



10
11
12
# File 'lib/wenlin_db_scanner/db_record.rb', line 10

def text
  @text
end