Class: EhbrsRubyUtils::Videos2::Unsupported::Profiles::Base
- Inherits:
-
Object
- Object
- EhbrsRubyUtils::Videos2::Unsupported::Profiles::Base
- Includes:
- Singleton
- Defined in:
- lib/ehbrs_ruby_utils/videos2/unsupported/profiles/base.rb
Constant Summary collapse
- CONSTANT_PREFIXES =
%w[video audio subtitle other].freeze
Instance Method Summary collapse
- #add_check(name, *args) ⇒ Object
- #added_checks ⇒ Object
- #base_checks ⇒ Object
- #checks ⇒ Object
- #codec_extra_checks(codec) ⇒ Object
- #codec_extras(codec, suffix) ⇒ Object
- #codec_supported_extras(codec) ⇒ Object
- #codec_unlisted_extra_check(codec) ⇒ Object
- #codec_unsupported_extras(codec) ⇒ Object
- #codecs_by_constant(middle) ⇒ Object
- #codecs_by_prefix(prefix, middle) ⇒ Object
- #file_checks ⇒ Object
- #name ⇒ Object
- #supported_codecs_uncached ⇒ Object
- #to_s ⇒ Object
- #track_checks ⇒ Object
- #unlisted_codec_check ⇒ Object
- #unsupported_codec_checks ⇒ Object
- #unsupported_codecs_uncached ⇒ Object
Instance Method Details
#add_check(name, *args) ⇒ Object
17 18 19 20 |
# File 'lib/ehbrs_ruby_utils/videos2/unsupported/profiles/base.rb', line 17 def add_check(name, *args) check_path = "ehbrs_ruby_utils/videos2/unsupported/checks/#{name}" added_checks << check_path.camelize.constantize.new(*args) end |
#added_checks ⇒ Object
13 14 15 |
# File 'lib/ehbrs_ruby_utils/videos2/unsupported/profiles/base.rb', line 13 def added_checks @added_checks ||= [] end |
#base_checks ⇒ Object
22 23 24 25 |
# File 'lib/ehbrs_ruby_utils/videos2/unsupported/profiles/base.rb', line 22 def base_checks [unlisted_codec_check] + unsupported_codec_checks + supported_codecs.flat_map { |codec| codec_extra_checks(codec) } end |
#checks ⇒ Object
27 28 29 |
# File 'lib/ehbrs_ruby_utils/videos2/unsupported/profiles/base.rb', line 27 def checks base_checks + added_checks end |
#codec_extra_checks(codec) ⇒ Object
39 40 41 42 43 44 45 |
# File 'lib/ehbrs_ruby_utils/videos2/unsupported/profiles/base.rb', line 39 def codec_extra_checks(codec) codec_unlisted_extra_check(codec).if_present([]) { |v| [v] } + codec_unsupported_extras(codec).map do |extra| EhbrsRubyUtils::Videos2::Unsupported::Checks::CodecExtraUnsupported.new(codec, extra) end end |
#codec_extras(codec, suffix) ⇒ Object
94 95 96 97 98 |
# File 'lib/ehbrs_ruby_utils/videos2/unsupported/profiles/base.rb', line 94 def codec_extras(codec, suffix) self.class.const_get("#{codec}_extra_#{suffix}".upcase) rescue NameError [] end |
#codec_supported_extras(codec) ⇒ Object
104 105 106 |
# File 'lib/ehbrs_ruby_utils/videos2/unsupported/profiles/base.rb', line 104 def codec_supported_extras(codec) codec_extras(codec, 'supported') end |
#codec_unlisted_extra_check(codec) ⇒ Object
47 48 49 50 51 52 53 54 |
# File 'lib/ehbrs_ruby_utils/videos2/unsupported/profiles/base.rb', line 47 def codec_unlisted_extra_check(codec) extras = codec_unsupported_extras(codec) + codec_supported_extras(codec) return nil unless extras.any? EhbrsRubyUtils::Videos2::Unsupported::Checks::CodecExtraUnlisted.new( codec, extras.sort.uniq ) end |
#codec_unsupported_extras(codec) ⇒ Object
100 101 102 |
# File 'lib/ehbrs_ruby_utils/videos2/unsupported/profiles/base.rb', line 100 def codec_unsupported_extras(codec) codec_extras(codec, 'unsupported') end |
#codecs_by_constant(middle) ⇒ Object
84 85 86 |
# File 'lib/ehbrs_ruby_utils/videos2/unsupported/profiles/base.rb', line 84 def codecs_by_constant(middle) CONSTANT_PREFIXES.inject([]) { |a, e| a + codecs_by_prefix(e, middle) } end |
#codecs_by_prefix(prefix, middle) ⇒ Object
88 89 90 91 92 |
# File 'lib/ehbrs_ruby_utils/videos2/unsupported/profiles/base.rb', line 88 def codecs_by_prefix(prefix, middle) self.class.const_get("#{prefix}_#{middle}_codecs".upcase) rescue NameError [] end |
#file_checks ⇒ Object
31 32 33 |
# File 'lib/ehbrs_ruby_utils/videos2/unsupported/profiles/base.rb', line 31 def file_checks checks.select { |c| check_type(c) == :container } end |
#name ⇒ Object
56 57 58 |
# File 'lib/ehbrs_ruby_utils/videos2/unsupported/profiles/base.rb', line 56 def name self.class.name.demodulize.underscore end |
#supported_codecs_uncached ⇒ Object
80 81 82 |
# File 'lib/ehbrs_ruby_utils/videos2/unsupported/profiles/base.rb', line 80 def supported_codecs_uncached codecs_by_constant('supported') end |
#to_s ⇒ Object
60 61 62 |
# File 'lib/ehbrs_ruby_utils/videos2/unsupported/profiles/base.rb', line 60 def to_s name end |
#track_checks ⇒ Object
35 36 37 |
# File 'lib/ehbrs_ruby_utils/videos2/unsupported/profiles/base.rb', line 35 def track_checks checks.select { |c| check_type(c) == :stream } end |
#unlisted_codec_check ⇒ Object
74 75 76 77 78 |
# File 'lib/ehbrs_ruby_utils/videos2/unsupported/profiles/base.rb', line 74 def unlisted_codec_check ::EhbrsRubyUtils::Videos2::Unsupported::Checks::CodecUnlisted.new( (supported_codecs + unsupported_codecs).sort.uniq ) end |
#unsupported_codec_checks ⇒ Object
64 65 66 67 68 |
# File 'lib/ehbrs_ruby_utils/videos2/unsupported/profiles/base.rb', line 64 def unsupported_codec_checks unsupported_codecs.map do |codec| EhbrsRubyUtils::Videos2::Unsupported::Checks::CodecUnsupported.new(codec) end end |
#unsupported_codecs_uncached ⇒ Object
70 71 72 |
# File 'lib/ehbrs_ruby_utils/videos2/unsupported/profiles/base.rb', line 70 def unsupported_codecs_uncached codecs_by_constant('unsupported') end |