Sha256: b78f48cac17f35c0b02838abf0f210ed5d744cbd77340a972928a4361fe32407

Contents?: true

Size: 1.07 KB

Versions: 9

Compression:

Stored size: 1.07 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 codec_name codec_long_name].each do |method_name|
        define_method method_name do
          ffprobe_data.fetch(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
    end
  end
end

Version data entries

9 entries across 9 versions & 2 rubygems

Version Path
ehbrs-tools-0.23.0 vendor/ehbrs_ruby_utils/lib/ehbrs_ruby_utils/videos/stream.rb
ehbrs-tools-0.22.0 vendor/ehbrs_ruby_utils/lib/ehbrs_ruby_utils/videos/stream.rb
ehbrs-tools-0.21.0 vendor/ehbrs_ruby_utils/lib/ehbrs_ruby_utils/videos/stream.rb
ehbrs-tools-0.20.0 vendor/ehbrs_ruby_utils/lib/ehbrs_ruby_utils/videos/stream.rb
ehbrs-tools-0.19.0 vendor/ehbrs_ruby_utils/lib/ehbrs_ruby_utils/videos/stream.rb
ehbrs-tools-0.18.0 vendor/ehbrs_ruby_utils/lib/ehbrs_ruby_utils/videos/stream.rb
ehbrs-tools-0.17.0 vendor/ehbrs_ruby_utils/lib/ehbrs_ruby_utils/videos/stream.rb
ehbrs_ruby_utils-0.5.1 lib/ehbrs_ruby_utils/videos/stream.rb
ehbrs-tools-0.16.5 vendor/ehbrs_ruby_utils/lib/ehbrs_ruby_utils/videos/stream.rb