Class: Animoto::ResponseParsers::Base Abstract

Inherits:
Object
  • Object
show all
Defined in:
lib/animoto/response_parsers/base.rb

Overview

This class is abstract.

Override #parse, #unparse, and #format (or set @format on the class) to subclass.

Direct Known Subclasses

JSONAdapter, YajlAdapter

Class Method Summary collapse

Instance Method Summary collapse

Class Method Details

.formatString

Returns the format of this parser class.

Returns:

  • (String)

    the format



16
17
18
# File 'lib/animoto/response_parsers/base.rb', line 16

def self.format
  @format
end

Instance Method Details

#formatString

Returns the format of this parser.

Returns:

  • (String)

    the format



23
24
25
# File 'lib/animoto/response_parsers/base.rb', line 23

def format
  self.class.format
end

#parse(body) ⇒ Hash{String=>Object}

This method is abstract.

Parses a response body into a usable Hash.

Parameters:

  • body (String)

    the HTTP response body

Returns:

  • (Hash{String=>Object})

    the parsed response

Raises:



33
34
35
# File 'lib/animoto/response_parsers/base.rb', line 33

def parse body
  raise AbstractMethodError
end

#unparse(hash) ⇒ String

This method is abstract.

Serializes a Hash into the format for this parser.

Parameters:

  • hash (Hash{Object=>Object})

    the hash to serialize

Returns:

  • (String)

    the serialized data

Raises:



43
44
45
# File 'lib/animoto/response_parsers/base.rb', line 43

def unparse hash
  raise AbstractMethodError
end