Class: Blender3d::FileHeader
- Inherits:
-
Object
- Object
- Blender3d::FileHeader
- Defined in:
- lib/blender-3d/file_header.rb
Instance Attribute Summary collapse
-
#endian_code ⇒ Object
readonly
Returns the value of attribute endian_code.
-
#endianness ⇒ Object
Returns the value of attribute endianness.
-
#identifier ⇒ Object
Returns the value of attribute identifier.
-
#pointer_size ⇒ Object
Returns the value of attribute pointer_size.
-
#size_code ⇒ Object
readonly
Returns the value of attribute size_code.
-
#version ⇒ Object
Returns the value of attribute version.
Instance Method Summary collapse
- #big_endian? ⇒ Boolean
- #deserialize(file) ⇒ Object
-
#initialize(file = nil) ⇒ FileHeader
constructor
A new instance of FileHeader.
- #little_endian? ⇒ Boolean
Constructor Details
#initialize(file = nil) ⇒ FileHeader
Returns a new instance of FileHeader.
9 10 11 |
# File 'lib/blender-3d/file_header.rb', line 9 def initialize(file = nil) deserialize(file) if file end |
Instance Attribute Details
#endian_code ⇒ Object (readonly)
Returns the value of attribute endian_code.
6 7 8 |
# File 'lib/blender-3d/file_header.rb', line 6 def endian_code @endian_code end |
#endianness ⇒ Object
Returns the value of attribute endianness.
6 7 8 |
# File 'lib/blender-3d/file_header.rb', line 6 def endianness @endianness end |
#identifier ⇒ Object
Returns the value of attribute identifier.
3 4 5 |
# File 'lib/blender-3d/file_header.rb', line 3 def identifier @identifier end |
#pointer_size ⇒ Object
Returns the value of attribute pointer_size.
6 7 8 |
# File 'lib/blender-3d/file_header.rb', line 6 def pointer_size @pointer_size end |
#size_code ⇒ Object (readonly)
Returns the value of attribute size_code.
6 7 8 |
# File 'lib/blender-3d/file_header.rb', line 6 def size_code @size_code end |
#version ⇒ Object
Returns the value of attribute version.
3 4 5 |
# File 'lib/blender-3d/file_header.rb', line 3 def version @version end |
Instance Method Details
#big_endian? ⇒ Boolean
35 36 37 |
# File 'lib/blender-3d/file_header.rb', line 35 def big_endian? !little_endian? end |
#deserialize(file) ⇒ Object
13 14 15 16 17 18 19 |
# File 'lib/blender-3d/file_header.rb', line 13 def deserialize(file) self.identifier = file.read(7) self.pointer_size = file.read(1) == '-'.freeze ? 8 : 4 self.endianness = file.read(1) == 'v'.freeze ? :little : :big self.version = file.read(1) + '.'.freeze + file.read(2) self end |
#little_endian? ⇒ Boolean
31 32 33 |
# File 'lib/blender-3d/file_header.rb', line 31 def little_endian? @endianness == :little end |