Class: RubySMB::Fscc::EaInfoArray
- Inherits:
-
BinData::Array
- Object
- BinData::Array
- RubySMB::Fscc::EaInfoArray
- Defined in:
- lib/ruby_smb/fscc/ea_info_array.rb
Overview
Convenience class that extend the normal BinData::Array for use with FileFullEaInfo. This array will automatically updates the FileFullEaInfo#next_entry_offset of each element in the array.
Instance Method Summary collapse
-
#[]=(index, value) ⇒ Object
Overrides the method from BinData::Array to call #update_offsets.
-
#insert(index, *objs) ⇒ self
Overrides the insert method in BinData::Array to call #update_offsets.
-
#update_offsets ⇒ self
Iterates through all of the elements in the array and dynamically updates all of the next_record_offset fields to properly reflect the chain.
Instance Method Details
#[]=(index, value) ⇒ Object
Overrides the method from BinData::Array to call #update_offsets
11 12 13 14 15 16 17 18 |
# File 'lib/ruby_smb/fscc/ea_info_array.rb', line 11 def []=(index, value) unless value.is_a? RubySMB::Fscc::FileFullEaInfo raise ArgumentError, 'This array can only contain RubySMB::Fscc::FileFullEaInfo objects' end retval = super(index, value) update_offsets retval end |
#insert(index, *objs) ⇒ self
Overrides the insert method in BinData::Array to call #update_offsets.
27 28 29 30 31 32 33 34 35 |
# File 'lib/ruby_smb/fscc/ea_info_array.rb', line 27 def insert(index, *objs) objs.each do |x| unless x.is_a? RubySMB::Fscc::FileFullEaInfo raise ArgumentError, 'This array can only contain RubySMB::Fscc::FileFullEaInfo objects' end end super(index, *objs) update_offsets end |
#update_offsets ⇒ self
Iterates through all of the elements in the array and dynamically updates all of the next_record_offset fields to properly reflect the chain.
42 43 44 45 46 47 48 49 50 51 52 53 |
# File 'lib/ruby_smb/fscc/ea_info_array.rb', line 42 def update_offsets each do |element| if element == last # If this is the end of our array, the offset must be 0 element.next_entry_offset = 0 else # If there is an element after this one, set the offset element.next_entry_offset = element.do_num_bytes end end self end |