Module: Ritm::Encodings

Defined in:
lib/ritm/helpers/encodings.rb

Overview

ENCODER/DECODER of HTTP content

Constant Summary collapse

ENCODINGS =
%i[identity gzip deflate].freeze

Class Method Summary collapse

Class Method Details

.decode(encoding, data) ⇒ Object



21
22
23
24
25
26
27
28
29
30
31
32
# File 'lib/ritm/helpers/encodings.rb', line 21

def self.decode(encoding, data)
  case encoding
  when :gzip
    decode_gzip(data)
  when :deflate
    decode_deflate(data)
  when :identity
    identity(data)
  else
    raise "Unsupported encoding #{encoding}"
  end
end

.encode(encoding, data) ⇒ Object



8
9
10
11
12
13
14
15
16
17
18
19
# File 'lib/ritm/helpers/encodings.rb', line 8

def self.encode(encoding, data)
  case encoding
  when :gzip
    encode_gzip(data)
  when :deflate
    encode_deflate(data)
  when :identity
    identity(data)
  else
    raise "Unsupported encoding #{encoding}"
  end
end