Class: MppReader::Cfbf::Entry
- Inherits:
-
Object
- Object
- MppReader::Cfbf::Entry
- Defined in:
- lib/mpp_reader/cfbf/directory.rb
Overview
One 128-byte directory entry: a storage (folder), stream (file), or root.
Constant Summary collapse
- TYPE_STORAGE =
1- TYPE_STREAM =
2- TYPE_ROOT =
5
Instance Attribute Summary collapse
-
#child ⇒ Object
readonly
Returns the value of attribute child.
-
#children ⇒ Object
Returns the value of attribute children.
-
#left ⇒ Object
readonly
Returns the value of attribute left.
-
#name ⇒ Object
readonly
Returns the value of attribute name.
-
#right ⇒ Object
readonly
Returns the value of attribute right.
-
#size ⇒ Object
readonly
Returns the value of attribute size.
-
#start_sector ⇒ Object
readonly
Returns the value of attribute start_sector.
-
#type ⇒ Object
readonly
Returns the value of attribute type.
Instance Method Summary collapse
-
#initialize(record) ⇒ Entry
constructor
A new instance of Entry.
- #storage? ⇒ Boolean
- #stream? ⇒ Boolean
Constructor Details
#initialize(record) ⇒ Entry
Returns a new instance of Entry.
12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 |
# File 'lib/mpp_reader/cfbf/directory.rb', line 12 def initialize(record) name_len = record.byteslice(64, 2).unpack1("v") name_len = 64 if name_len > 64 @name = if name_len >= 2 record.byteslice(0, name_len - 2) .force_encoding(Encoding::UTF_16LE) .encode(Encoding::UTF_8, invalid: :replace, undef: :replace) else "" end @type = record.getbyte(66) @left, @right, @child = record.byteslice(68, 12).unpack("V3") @start_sector = record.byteslice(116, 4).unpack1("V") @size = record.byteslice(120, 8).unpack1("Q<") @children = {} end |
Instance Attribute Details
#child ⇒ Object (readonly)
Returns the value of attribute child.
9 10 11 |
# File 'lib/mpp_reader/cfbf/directory.rb', line 9 def child @child end |
#children ⇒ Object
Returns the value of attribute children.
10 11 12 |
# File 'lib/mpp_reader/cfbf/directory.rb', line 10 def children @children end |
#left ⇒ Object (readonly)
Returns the value of attribute left.
9 10 11 |
# File 'lib/mpp_reader/cfbf/directory.rb', line 9 def left @left end |
#name ⇒ Object (readonly)
Returns the value of attribute name.
9 10 11 |
# File 'lib/mpp_reader/cfbf/directory.rb', line 9 def name @name end |
#right ⇒ Object (readonly)
Returns the value of attribute right.
9 10 11 |
# File 'lib/mpp_reader/cfbf/directory.rb', line 9 def right @right end |
#size ⇒ Object (readonly)
Returns the value of attribute size.
9 10 11 |
# File 'lib/mpp_reader/cfbf/directory.rb', line 9 def size @size end |
#start_sector ⇒ Object (readonly)
Returns the value of attribute start_sector.
9 10 11 |
# File 'lib/mpp_reader/cfbf/directory.rb', line 9 def start_sector @start_sector end |
#type ⇒ Object (readonly)
Returns the value of attribute type.
9 10 11 |
# File 'lib/mpp_reader/cfbf/directory.rb', line 9 def type @type end |
Instance Method Details
#storage? ⇒ Boolean
29 |
# File 'lib/mpp_reader/cfbf/directory.rb', line 29 def storage? = @type == TYPE_STORAGE || @type == TYPE_ROOT |
#stream? ⇒ Boolean
30 |
# File 'lib/mpp_reader/cfbf/directory.rb', line 30 def stream? = @type == TYPE_STREAM |