class DataTypes::UInt16

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 70
def initialize(options = {})
  super options.merge :bit_length => 16, :sign => :unsigned
end

Public Instance Methods

dump(value=nil) click to toggle source
# File lib/active_model_serializers_binary/data_types.rb, line 74
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 83
def load(raw_value) 
  @raw_value = check_raw_value(raw_value)
  if @endianess == :big
    self.value = @raw_value.pack('C*').unpack('S>*')
  else
    self.value = @raw_value.pack('C*').unpack('S<*')
  end
  after_load
end