Class: TranscodingMachine::MediaFormat
- Inherits:
-
Object
- Object
- TranscodingMachine::MediaFormat
- Defined in:
- lib/transcoding_machine/media_format.rb
Direct Known Subclasses
Instance Attribute Summary collapse
-
#command ⇒ Object
readonly
Returns the value of attribute command.
-
#criteria ⇒ Object
readonly
Returns the value of attribute criteria.
-
#id ⇒ Object
readonly
Returns the value of attribute id.
-
#mime_type ⇒ Object
readonly
Returns the value of attribute mime_type.
-
#priority ⇒ Object
readonly
Returns the value of attribute priority.
-
#suffix ⇒ Object
readonly
Returns the value of attribute suffix.
Class Method Summary collapse
- .best_match_for(media_file_attributes, sorted_formats) ⇒ Object
- .type_cast_attribute_value(key, value) ⇒ Object
Instance Method Summary collapse
- #can_transcode?(media_file_attributes) ⇒ Boolean
-
#initialize(args) ⇒ MediaFormat
constructor
A new instance of MediaFormat.
- #matches(media_file_attributes) ⇒ Object
Constructor Details
#initialize(args) ⇒ MediaFormat
Returns a new instance of MediaFormat.
8 9 10 11 12 13 14 15 16 |
# File 'lib/transcoding_machine/media_format.rb', line 8 def initialize(args) @fixed_criteria = [] @priority = args[:priority] @id = args[:id] @suffix = args[:suffix] @mime_type = args[:mime_type] @command = args[:command] @criteria = args[:criteria] || [] end |
Instance Attribute Details
#command ⇒ Object (readonly)
Returns the value of attribute command.
6 7 8 |
# File 'lib/transcoding_machine/media_format.rb', line 6 def command @command end |
#criteria ⇒ Object (readonly)
Returns the value of attribute criteria.
6 7 8 |
# File 'lib/transcoding_machine/media_format.rb', line 6 def criteria @criteria end |
#id ⇒ Object (readonly)
Returns the value of attribute id.
6 7 8 |
# File 'lib/transcoding_machine/media_format.rb', line 6 def id @id end |
#mime_type ⇒ Object (readonly)
Returns the value of attribute mime_type.
6 7 8 |
# File 'lib/transcoding_machine/media_format.rb', line 6 def mime_type @mime_type end |
#priority ⇒ Object (readonly)
Returns the value of attribute priority.
6 7 8 |
# File 'lib/transcoding_machine/media_format.rb', line 6 def priority @priority end |
#suffix ⇒ Object (readonly)
Returns the value of attribute suffix.
6 7 8 |
# File 'lib/transcoding_machine/media_format.rb', line 6 def suffix @suffix end |
Class Method Details
.best_match_for(media_file_attributes, sorted_formats) ⇒ Object
43 44 45 |
# File 'lib/transcoding_machine/media_format.rb', line 43 def self.best_match_for(media_file_attributes, sorted_formats) sorted_formats.first {|f| f.can_transcode?(media_file_attributes)} end |
.type_cast_attribute_value(key, value) ⇒ Object
26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 |
# File 'lib/transcoding_machine/media_format.rb', line 26 def self.type_cast_attribute_value(key, value) case Server::MediaFileAttributes::FIELD_TYPES[key] when :boolean (value.to_s.downcase == 'true' || value.to_s == '1') when :string value.to_s when :integer value.to_i when :float value.to_f when :codec value.to_sym else raise "unknown key (#{key}) for MediaFormat attribute" end end |
Instance Method Details
#can_transcode?(media_file_attributes) ⇒ Boolean
22 23 24 |
# File 'lib/transcoding_machine/media_format.rb', line 22 def can_transcode?(media_file_attributes) end |
#matches(media_file_attributes) ⇒ Object
18 19 20 |
# File 'lib/transcoding_machine/media_format.rb', line 18 def matches(media_file_attributes) (@fixed_criteria + @criteria).all? { |c| c.matches(media_file_attributes) } end |