Sha256: 9fbebdf15226832faf283ebb98cb4163f4212eca6c7268ac69d3d68462ebe95e

Contents?: true

Size: 1.15 KB

Versions: 3

Compression:

Stored size: 1.15 KB

Contents

module Animoto
  module ResponseParsers    
    extend Support::DynamicClassLoader(File.expand_path(File.dirname(__FILE__)))
    
    # @abstract Override {#parse} and {#unparse} to subclass.
    class Base
    
      # Returns the format of this parser class.
      # 
      # @return [String] the format
      def self.format
        @format
      end
    
      # Returns the format of this parser.
      #
      # @return [String] the format
      def format
        self.class.format
      end
    
      # Parses a response body into a usable Hash.
      #
      # @abstract
      # @param [String] body the HTTP response body
      # @return [Hash<String,Object>] the parsed response
      # @raise [NotImplementedError] if called on the abstract class
      def parse body
        raise NotImplementedError
      end
    
      # Serializes a Hash into the format for this parser.
      #
      # @abstract
      # @param [Hash<Object,Object>] hash the hash to serialize
      # @return [String] the serialized data
      # @raise [NotImplementedError] if called on the abstract class
      def unparse hash
        raise NotImplementedError
      end

    end
  end
end

Version data entries

3 entries across 3 versions & 1 rubygems

Version Path
animoto-0.1.1.beta1 ./lib/animoto/response_parsers/base.rb
animoto-0.1.0.beta1 ./lib/animoto/response_parsers/base.rb
animoto-0.1.0.beta0 ./lib/animoto/response_parsers/base.rb