Class: ActiveRecordEncryption::Binary

Inherits:
StringIO
  • Object
show all
Defined in:
lib/active_record_encryption/binary.rb

Constant Summary collapse

FORMATS =
{
  u_long_long: {
    length: 8,
    code: 'Q>'
  },
  long_long: {
    length: 8,
    code: 'q>'
  },
  u_int: {
    length: 4,
    code: 'L>'
  },
  int: {
    length: 4,
    code: 'l>'
  },
  u_short: {
    length: 2,
    code: 'S>'
  },
  short: {
    length: 2,
    code: 's>'
  },
  u_char: {
    length: 1,
    code: 'C'
  },
  char: {
    length: 1,
    code: 'c'
  }
}.freeze

Instance Method Summary collapse

Constructor Details

#initializeBinary

Returns a new instance of Binary.



54
55
56
57
# File 'lib/active_record_encryption/binary.rb', line 54

def initialize(*)
  super
  binmode
end

Instance Method Details

#read_string_255Object



64
65
66
# File 'lib/active_record_encryption/binary.rb', line 64

def read_string_255
  read(read_u_char)
end

#write_string_255(value) ⇒ Object



59
60
61
62
# File 'lib/active_record_encryption/binary.rb', line 59

def write_string_255(value)
  write_u_char(value.bytesize)
  write(value)
end