Sha256: b65aab3323c07e0cb99f19ae698f95c15ffa904c26684af760a76e9c54abb319

Contents?: true

Size: 868 Bytes

Versions: 5

Compression:

Stored size: 868 Bytes

Contents

# frozen_string_literal: true

module AzureSTT
  module Parsers
    #
    # Base class for the parsers
    #
    class Base
      attr_reader :hash

      #
      # Initialize the parser
      #
      # @param [Hash] hash The hash containing the information from the API
      #
      def initialize(hash)
        @hash = hash
      end

      #
      # Get the attributes parsed to be able to build the model
      #
      # @return [Hash]
      #
      def attributes
        @attributes ||= build_attributes
      end

      protected

      #
      # This method must be overriden in the children
      #
      # @return [Hash] The attributes parsed to be able to build the model
      #
      def build_attributes
        raise NoMethodError, 'Implement method #build_attributes in your' \
                             'custom parser'
      end
    end
  end
end

Version data entries

5 entries across 5 versions & 1 rubygems

Version Path
azure_stt-0.4.0 lib/azure_stt/parsers/base.rb
azure_stt-0.3.0 lib/azure_stt/parsers/base.rb
azure_stt-0.2.0 lib/azure_stt/parsers/base.rb
azure_stt-0.1.1 lib/azure_stt/parsers/base.rb
azure_stt-0.1.0 lib/azure_stt/parsers/base.rb