Class: DataTypes::Int8

Inherits:
BaseType show all
Defined in:
lib/active_model_serializers_binary/data_types.rb

Instance Attribute Summary

Attributes inherited from BaseType

#bit_length, #count, #length, #name, #parent, #raw_value, #sign, #type, #value

Instance Method Summary collapse

Methods inherited from BaseType

#after_load, #before_dump, #check, #check_raw_value, #check_value, #size, #to_s, #trim

Constructor Details

#initialize(options = {}) ⇒ Int8



6
7
8
# File 'lib/active_model_serializers_binary/data_types.rb', line 6

def initialize(options = {})
  super options.merge :bit_length => 8, :sign => :signed
end

Instance Method Details

#dump(value = nil) ⇒ Object



10
11
12
13
# File 'lib/active_model_serializers_binary/data_types.rb', line 10

def dump(value=nil)
  before_dump( value ).pack('c*').unpack('C*')
  @raw_value = @value
end

#load(raw_value) ⇒ Object



15
16
17
18
# File 'lib/active_model_serializers_binary/data_types.rb', line 15

def load(raw_value)
  self.value = check_raw_value(raw_value).pack('C*').unpack('c*')
  after_load
end