Class: WenlinDbScanner::DbRecord
- Inherits:
-
Object
- Object
- WenlinDbScanner::DbRecord
- Defined in:
- lib/wenlin_db_scanner/db_record.rb
Overview
Wraps record data returned by WenlinDbScanner::Db methods.
Instance Attribute Summary collapse
-
#binary ⇒ Boolean
(also: #binary?)
readonly
True if the record has non-text data, such as pictures.
-
#data ⇒ String?
readonly
ASCII-8BIT encoded binary data; nil for text records.
-
#offset ⇒ Object
readonly
The record’s position in the database.
-
#size ⇒ Object
readonly
Raw data size, in bytes.
-
#tag ⇒ Fixnum
readonly
The record’s tag byte (a number in 0…256).
-
#text ⇒ String?
readonly
UTF-8 encoded text data; nil for binary records.
Instance Method Summary collapse
-
#initialize(offset, tag, size, binary, data) ⇒ DbRecord
constructor
Used by the WenlinDbScanner::Db methods.
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
#binary ⇒ Boolean (readonly) Also known as: binary?
Returns 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 |
#data ⇒ String? (readonly)
Returns 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 |
#offset ⇒ Object (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 |
#size ⇒ Object (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 |
#tag ⇒ Fixnum (readonly)
Returns 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 |
#text ⇒ String? (readonly)
Returns 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 |