Module: RubySerial

Defined in:
lib/ruby-serial.rb,
lib/ruby-serial/common.rb,
lib/ruby-serial/serializer.rb,
lib/ruby-serial/deserializer.rb,
lib/ruby-serial/versions/1/serializer.rb,
lib/ruby-serial/versions/1/deserializer.rb

Defined Under Namespace

Classes: Deserializer, Serializer

Constant Summary collapse

OBJECT_ID_REFERENCE =

Following are used as Hash keys. No duplicates allowed.

"\x00\xA0".force_encoding(Encoding::UTF_8)
OBJECT_CONTENT_REFERENCE =
"\x00\xF1".force_encoding(Encoding::UTF_8)
OBJECT_CLASSNAME_REFERENCE =
"\x00\xBB".force_encoding(Encoding::UTF_8)
CLASS_ID_SYMBOL =

Following are used as class identifiers in Hash values. No duplicates allowed.

"\x00\xEE".force_encoding(Encoding::UTF_8)
CLASS_ID_ENCODING =
"\x00\xDD".force_encoding(Encoding::UTF_8)
CLASS_ID_RANGE =
"\x00\xCC".force_encoding(Encoding::UTF_8)

Class Method Summary collapse

Class Method Details

.dump(obj, options = {}) ⇒ Object

Serialize an object into a String

Parameters
  • obj (Object): Object to serialize

  • options (map<Symbol,Object>): Options [default = {}]

    • :version (String): The version to be used to encode

Result
  • String: Serialized object



18
19
20
# File 'lib/ruby-serial.rb', line 18

def self.dump(obj, options = {})
  return Serializer.new(obj, options).dump
end

.load(data) ⇒ Object

Deserialize an object from a String

Parameters
  • data (String): Data to deserialize

Result
  • Object: Corresponding Ruby object



28
29
30
# File 'lib/ruby-serial.rb', line 28

def self.load(data)
  return Deserializer.new(data).load
end