Sha256: 89be047892ce189733107e8d26831792d4243a9828aae7a9ca1469109c05542c

Contents?: true

Size: 1.25 KB

Versions: 14

Compression:

Stored size: 1.25 KB

Contents

# frozen_string_literal: true

require 'eac_ruby_utils/core_ext'

module EhbrsRubyUtils
  module Videos
    class Stream
      enable_simple_cache
      enable_listable

      lists.add_symbol :codec_type, :audio, :video, :subtitle, :data, :attachment

      common_constructor :ffprobe_data do
        self.ffprobe_data = ffprobe_data.symbolize_keys.freeze
        self.class.lists.codec_type.value_validate!(codec_type)
      end

      lists.codec_type.each_value do |v|
        define_method "#{v}?" do
          codec_type == v
        end
      end

      def to_s
        "#{index}|#{codec_type}|#{codec_name}|#{language}"
      end

      def to_h
        ffprobe_data
      end

      %i[index].each do |method_name|
        define_method method_name do
          ffprobe_data.fetch(method_name)
        end
      end

      %i[codec_name codec_long_name height width].each do |method_name|
        define_method method_name do
          ffprobe_data[method_name]
        end
      end

      def codec_type
        ffprobe_data.fetch(:codec_type).to_sym
      end

      def tags
        ffprobe_data[:tags].if_present({}, &:symbolize_keys)
      end

      def language
        tags[:language]
      end

      def title
        tags[:title]
      end
    end
  end
end

Version data entries

14 entries across 14 versions & 2 rubygems

Version Path
ehbrs_ruby_utils-0.14.0 lib/ehbrs_ruby_utils/videos/stream.rb
ehbrs_ruby_utils-0.13.0 lib/ehbrs_ruby_utils/videos/stream.rb
ehbrs_ruby_utils-0.12.2 lib/ehbrs_ruby_utils/videos/stream.rb
ehbrs-tools-0.28.3 vendor/ehbrs_ruby_utils/lib/ehbrs_ruby_utils/videos/stream.rb
ehbrs_ruby_utils-0.12.1 lib/ehbrs_ruby_utils/videos/stream.rb
ehbrs-tools-0.28.2 vendor/ehbrs_ruby_utils/lib/ehbrs_ruby_utils/videos/stream.rb
ehbrs-tools-0.28.1 vendor/ehbrs_ruby_utils/lib/ehbrs_ruby_utils/videos/stream.rb
ehbrs_ruby_utils-0.12.0 lib/ehbrs_ruby_utils/videos/stream.rb
ehbrs-tools-0.28.0 vendor/ehbrs_ruby_utils/lib/ehbrs_ruby_utils/videos/stream.rb
ehbrs_ruby_utils-0.11.0 lib/ehbrs_ruby_utils/videos/stream.rb
ehbrs-tools-0.27.0 vendor/ehbrs_ruby_utils/lib/ehbrs_ruby_utils/videos/stream.rb
ehbrs_ruby_utils-0.10.0 lib/ehbrs_ruby_utils/videos/stream.rb
ehbrs-tools-0.26.0 vendor/ehbrs_ruby_utils/lib/ehbrs_ruby_utils/videos/stream.rb
ehbrs_ruby_utils-0.9.0 lib/ehbrs_ruby_utils/videos/stream.rb