Sha256: 6f714105b48e2c0d5d4976abb65eff1cc40b9dc7eb4496e6a40069f1aacb0f43

Contents?: true

Size: 924 Bytes

Versions: 2

Compression:

Stored size: 924 Bytes

Contents

# frozen_string_literal: true

require 'link_thumbnailer/model'
require 'link_thumbnailer/video_parser'

module LinkThumbnailer
  module Models
    class Video < ::LinkThumbnailer::Model

      attr_reader :src, :size, :duration, :provider, :id, :embed_code

      def initialize(src, size = nil)
        @src        = src
        @id         = parser.id
        @size       = size || parser.size
        @duration   = parser.duration
        @provider   = parser.provider
        @embed_code = parser.embed_code
      end

      def to_s
        src.to_s
      end

      def as_json(*)
        {
          id:         id,
          src:        src.to_s,
          size:       size,
          duration:   duration,
          provider:   provider,
          embed_code: embed_code
        }
      end

      private

      def parser
        @parser ||= ::LinkThumbnailer::VideoParser.new(self)
      end

    end
  end
end

Version data entries

2 entries across 2 versions & 1 rubygems

Version Path
link_thumbnailer-3.4.0 lib/link_thumbnailer/models/video.rb
link_thumbnailer-3.3.2 lib/link_thumbnailer/models/video.rb