Class: Airplay::Player::Media
- Inherits:
-
Object
- Object
- Airplay::Player::Media
- Defined in:
- lib/airplay/player/media.rb
Constant Summary collapse
- COMPATIBLE_TYPES =
%w( application/mp4 video/mp4 video/vnd.objectvideo video/MP2T video/quicktime video/mpeg4 )
Instance Attribute Summary collapse
-
#file_or_url ⇒ Object
readonly
Returns the value of attribute file_or_url.
-
#url ⇒ Object
readonly
Returns the value of attribute url.
Instance Method Summary collapse
- #compatible? ⇒ Boolean
-
#initialize(file_or_url) ⇒ Media
constructor
A new instance of Media.
- #local? ⇒ Boolean
- #remote? ⇒ Boolean
- #to_s ⇒ Object
Constructor Details
#initialize(file_or_url) ⇒ Media
Returns a new instance of Media.
19 20 21 |
# File 'lib/airplay/player/media.rb', line 19 def initialize(file_or_url) @file_or_url = file_or_url end |
Instance Attribute Details
#file_or_url ⇒ Object (readonly)
Returns the value of attribute file_or_url.
8 9 10 |
# File 'lib/airplay/player/media.rb', line 8 def file_or_url @file_or_url end |
#url ⇒ Object (readonly)
Returns the value of attribute url.
8 9 10 |
# File 'lib/airplay/player/media.rb', line 8 def url @url end |
Instance Method Details
#compatible? ⇒ Boolean
34 35 36 37 38 39 40 |
# File 'lib/airplay/player/media.rb', line 34 def compatible? @_compatible ||= begin path = File.basename(file_or_url) compatibility = MIME::Types.type_for(path).map(&:to_s) & COMPATIBLE_TYPES compatibility.any? end end |
#local? ⇒ Boolean
42 43 44 |
# File 'lib/airplay/player/media.rb', line 42 def local? File.exists?(file_or_url) end |
#remote? ⇒ Boolean
46 47 48 |
# File 'lib/airplay/player/media.rb', line 46 def remote? !!(file_or_url =~ URI::regexp) end |
#to_s ⇒ Object
50 |
# File 'lib/airplay/player/media.rb', line 50 def to_s; url end |