Class: Caf::Chunk::Data
Instance Attribute Summary collapse
-
#edit_count ⇒ Object
Returns the value of attribute edit_count.
-
#position ⇒ Object
Returns the value of attribute position.
-
#size ⇒ Object
Returns the value of attribute size.
Attributes inherited from Base
Instance Method Summary collapse
- #fields_size ⇒ Object
-
#initialize(chunk_header) ⇒ Data
constructor
A new instance of Data.
- #read_data(file) ⇒ Object
- #to_s ⇒ Object
- #validate ⇒ Object
Methods inherited from Base
#check_type_and_size, implements
Constructor Details
#initialize(chunk_header) ⇒ Data
Returns a new instance of Data.
14 15 16 |
# File 'lib/caf/chunk/data.rb', line 14 def initialize(chunk_header) super chunk_header end |
Instance Attribute Details
#edit_count ⇒ Object
Returns the value of attribute edit_count.
12 13 14 |
# File 'lib/caf/chunk/data.rb', line 12 def edit_count @edit_count end |
#position ⇒ Object
Returns the value of attribute position.
12 13 14 |
# File 'lib/caf/chunk/data.rb', line 12 def position @position end |
#size ⇒ Object
Returns the value of attribute size.
12 13 14 |
# File 'lib/caf/chunk/data.rb', line 12 def size @size end |
Instance Method Details
#fields_size ⇒ Object
28 29 30 |
# File 'lib/caf/chunk/data.rb', line 28 def fields_size raise(Caf::Error, "not implemented") end |
#read_data(file) ⇒ Object
32 33 34 35 36 37 38 39 40 41 42 43 44 |
# File 'lib/caf/chunk/data.rb', line 32 def read_data(file) edit = file.read(4) @edit_count = (edit.getbyte(0) << 32) + (edit.getbyte(1) << 16) + (edit.getbyte(2) << 8) + edit.getbyte(3) @position = file.pos unless chunk_size == -1 @size = chunk_size - 4 # 4 bytes are from edit_count field file.seek(@size, IO::SEEK_CUR) else file.seek(0, IO::SEEK_END) @size = file.pos - @position # TODO should update chunk_size field with @size + 4 if file is writable end end |
#to_s ⇒ Object
18 19 20 21 22 23 |
# File 'lib/caf/chunk/data.rb', line 18 def to_s "#{chunk_type} (data chunk):\n"+ " -edit count: #{edit_count}\n" + " -data size: #{size}\n" + " -data position: #{position}\n" end |
#validate ⇒ Object
25 26 |
# File 'lib/caf/chunk/data.rb', line 25 def validate end |