Class: HTTP::MimeType::Adapter

Inherits:
Object
  • Object
show all
Extended by:
Forwardable
Includes:
Singleton
Defined in:
lib/http/mime_type/adapter.rb,
sig/http.rbs

Overview

Base encode/decode MIME type adapter

Direct Known Subclasses

JSON

Class Method Summary collapse

Instance Method Summary collapse

Class Method Details

.decodeObject

Parameters:

  • (String)

Returns:

  • (Object)


594
# File 'sig/http.rbs', line 594

def self.decode: (String) -> untyped

.encodeString

Parameters:

  • (Object)

Returns:

  • (String)


593
# File 'sig/http.rbs', line 593

def self.encode: (untyped) -> String

Instance Method Details

#decodeObject

Decodes data from the MIME type format

Examples:

adapter.decode("{\"foo\":\"bar\"}")

Parameters:

  • (String)

Returns:

  • (Object)

    decoded data

Raises:

  • (Error)

    if not implemented by subclass



38
39
40
# File 'lib/http/mime_type/adapter.rb', line 38

def decode(*)
  raise Error, "#{self.class} does not supports #decode"
end

#encodeString

Encodes data into the MIME type format

Examples:

adapter.encode("foo" => "bar")

Parameters:

  • (Object)

Returns:

  • (String)

    encoded representation

Raises:

  • (Error)

    if not implemented by subclass



26
27
28
# File 'lib/http/mime_type/adapter.rb', line 26

def encode(*)
  raise Error, "#{self.class} does not supports #encode"
end