Sha256: 1476a6cea24ba5aeb0675de09258a8f45b0cf23d2d3ef8f6806cd99f447ae12c

Contents?: true

Size: 940 Bytes

Versions: 1

Compression:

Stored size: 940 Bytes

Contents

module DropboxApi::Metadata
  # Example of a serialized {MediaInfo} object:
  #   {
  #     ".tag": "metadata",
  #     "metadata": {
  #       ".tag": "video",
  #       "dimensions": {
  #         "height": 1500,
  #         "width": 1500
  #       },
  #       "location": {
  #         "latitude": 10.123456,
  #         "longitude": 5.123456
  #       }
  #       "time_taken": "2016-09-04T17:00:27Z",
  #       "duration": 6000
  #     }
  #   }
  class MediaInfo < Base
    class << self
      def new(data)
        tag = data['metadata']['.tag']
        class_for(tag.to_sym).new(data['metadata'])
      end

      private

      def class_for(tag)
        case tag
        when :photo
          DropboxApi::Metadata::PhotoMetadata
        when :video
          DropboxApi::Metadata::VideoMetadata
        else
          raise ArgumentError, "Unable to build individual result with `#{tag}`"
        end
      end
    end
  end
end

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
dropbox_api-0.1.9 lib/dropbox_api/metadata/media_info.rb