Sha256: 1d9e88002f921af147dd1523bac05c6fa3bd9432eba128fba8beb424e04a0031

Contents?: true

Size: 797 Bytes

Versions: 1

Compression:

Stored size: 797 Bytes

Contents

require_relative 'converter/record'
require_relative 'converter/records'
require_relative 'converter/boolean'
require_relative 'converter/datetime'
require_relative 'converter/errors'
require_relative 'converter/unknown'

module Typekit
  module Processing
    module Converter
      MAPPING = {
        'ok' => Boolean,
        'errors' => Errors,
        'published' => DateTime,
        nil => Errors
      }.freeze

      def self.build(name)
        if MAPPING.key?(name)
          MAPPING[name].new
        elsif Typekit::Record.collection?(name)
          Records.new(name)
        elsif Typekit::Record.member?(name)
          Record.new(name)
        else
          Unknown.new(name)
        end
      rescue NameError
        raise Error, 'Unknown converter'
      end
    end
  end
end

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
typekit-client-0.0.4 lib/typekit/processing/converter.rb