Class: RubyVolt::DataType::FixedSize

Inherits:
Basic show all
Defined in:
lib/ruby_volt/data_type/basic/fixed_size.rb

Direct Known Subclasses

Decimal, Float, GeographyPoint, IntegerType

Class Method Summary collapse

Methods inherited from Basic

bytesToInt, intToBytes

Methods inherited from RubyVolt::DataType

classifyDataType, testpacking, voltDataType

Class Method Details

.pack(val) ⇒ Object



6
7
8
9
# File 'lib/ruby_volt/data_type/basic/fixed_size.rb', line 6

def pack(val)
  val ||= self::NULL_INDICATOR
  [val].pack(self::DIRECTIVE)
end

.unpack(bytes) ⇒ Object



11
12
13
14
# File 'lib/ruby_volt/data_type/basic/fixed_size.rb', line 11

def unpack(bytes)
  unpacked = bytes.read(self::LENGTH).unpack1(self::DIRECTIVE)
  unpacked unless unpacked == self::NULL_INDICATOR
end