class DataTypes::Int16

Public Class Methods

new(options = {}) click to toggle source
Calls superclass method DataTypes::BaseType::new
# File lib/active_model_serializers_binary/data_types.rb, line 22
def initialize(options = {})
  super options.merge :bit_length => 16, :sign => :signed
end

Public Instance Methods

dump(value=nil) click to toggle source
# File lib/active_model_serializers_binary/data_types.rb, line 26
def dump(value=nil)
  before_dump( value )
  if @endianess == :big
    @raw_value = @value.pack('s>*').unpack('C*')
  else
    @raw_value = @value.pack('s<*').unpack('C*')
  end
end
load(raw_value) click to toggle source
# File lib/active_model_serializers_binary/data_types.rb, line 35
def load(raw_value)
  if @endianess == :big
    self.value = check_raw_value(raw_value).pack('C*').unpack('s>*')
  else
    self.value = check_raw_value(raw_value).pack('C*').unpack('s<*')
  end
  after_load
end