Class: Python::Pickle::ByteArray

Inherits:
String
  • Object
show all
Defined in:
lib/python/pickle/byte_array.rb

Overview

Represents a Python bytearray object.

Constant Summary collapse

ENCODINGS =

This constant is part of a private API. You should avoid using this constant if possible, as it may be removed or be changed in the future.

Mapping of python codecs encoding names and their Ruby equivalents.

{
  nil       => Encoding::ASCII_8BIT,
  'latin-1' => Encoding::ISO_8859_1
}

Instance Method Summary collapse

Constructor Details

#initialize(string = '', encoding = nil) ⇒ ByteArray

Initializes the byte array.

Parameters:

  • string (String) (defaults to: '')

    The contents of the byte array.

  • encoding (String, nil) (defaults to: nil)

    The optional encoding name.



25
26
27
# File 'lib/python/pickle/byte_array.rb', line 25

def initialize(string='', encoding=nil)
  super(string, encoding: ENCODINGS.fetch(encoding))
end

Instance Method Details

#inspectString

Inspects the byte array object.

Returns:

  • (String)


34
35
36
# File 'lib/python/pickle/byte_array.rb', line 34

def inspect
  "#<#{self.class}: #{super}>"
end