Class: MP4::Binary::FixedPoint8
- Inherits:
-
BinData::BasePrimitive
- Object
- BinData::BasePrimitive
- MP4::Binary::FixedPoint8
- Defined in:
- lib/mp4/binary/fixed_point8.rb
Instance Method Summary collapse
- #read_and_return_value(io) ⇒ Object
- #read_uint32(io) ⇒ Object
- #value_to_binary_string(value) ⇒ Object
Instance Method Details
#read_and_return_value(io) ⇒ Object
9 10 11 12 13 |
# File 'lib/mp4/binary/fixed_point8.rb', line 9 def read_and_return_value(io) raw_value = BinData::Int16be.read read_uint32(io) (raw_value / (2.0**8)).to_i end |
#read_uint32(io) ⇒ Object
15 16 17 |
# File 'lib/mp4/binary/fixed_point8.rb', line 15 def read_uint32(io) io.readbytes(2) end |
#value_to_binary_string(value) ⇒ Object
3 4 5 6 7 |
# File 'lib/mp4/binary/fixed_point8.rb', line 3 def value_to_binary_string(value) value = (value.to_i * (2.0**8)).to_i BinData::Int16be.new(value).to_binary_s end |