Class: Threatinator::Decoder

Inherits:
Object
  • Object
show all
Defined in:
lib/threatinator/decoder.rb

Overview

Decodes/Extracts data from an input IO, producing a new IO. The decoder is initialized with a configuration, and then #decode is called upon an IO object.

Direct Known Subclasses

Threatinator::Decoders::Gzip

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(opts = {}) ⇒ Decoder

Returns a new instance of Decoder.

Parameters:

  • opts (Hash) (defaults to: {})

    An options hash

Options Hash (opts):

  • :encoding (String)

    The encoding for the output IO. Defaults to “utf-8”



11
12
13
# File 'lib/threatinator/decoder.rb', line 11

def initialize(opts = {})
  @encoding = opts[:encoding] || "utf-8"
end

Instance Attribute Details

#encodingObject (readonly)

Returns the value of attribute encoding.



6
7
8
# File 'lib/threatinator/decoder.rb', line 6

def encoding
  @encoding
end

Instance Method Details

#decode(io) ⇒ IO

Decodes an input IO, returning a brand new IO.

Parameters:

  • io (IO)

    The IO to decode

Returns:

  • (IO)

    A new IO.

Raises:

  • (NotImplementedError)


18
19
20
21
22
# File 'lib/threatinator/decoder.rb', line 18

def decode(io)
  #:nocov:
  raise NotImplementedError.new("#{self.class}#decode not implemented!")
  #:nocov:
end