Class: RubySMB::Field::EaInfoArray
- Inherits:
-
BinData::Array
- Object
- BinData::Array
- RubySMB::Field::EaInfoArray
- Defined in:
- lib/ruby_smb/field/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
12 13 14 15 16 17 18 19 |
# File 'lib/ruby_smb/field/ea_info_array.rb', line 12 def []=(index, value) unless value.is_a? RubySMB::Field::FileFullEaInfo raise ArgumentError, "This array can only contain RubySMB::Field::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.
28 29 30 31 32 33 34 35 36 |
# File 'lib/ruby_smb/field/ea_info_array.rb', line 28 def insert(index, *objs) objs.each do |x| unless x.is_a? RubySMB::Field::FileFullEaInfo raise ArgumentError, "This array can only contain RubySMB::Field::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.
43 44 45 46 47 48 49 50 51 52 53 54 |
# File 'lib/ruby_smb/field/ea_info_array.rb', line 43 def update_offsets self.each do |element| if element == self.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 |