Class: BBC::Redux::MediaUrl
- Inherits:
-
Object
- Object
- BBC::Redux::MediaUrl
- Extended by:
- Forwardable
- Defined in:
- lib/bbc/redux/media_url.rb
Overview
Redux API Asset URL Object
Each asset is available as various transcodes using the url function. The urls are key based and therefore generally have a lifetime of 24 hours #
Defined Under Namespace
Classes: UnknownTemplateType
Constant Summary collapse
- TEMPLATES =
Known URL templates, these are the only valid options for the type attribute of MediaUrl.initialize.
[ :dvbsubs, :flv, :h264_hi, :h264_lo, :mp3, :ts, :ts_stripped ].freeze
Instance Attribute Summary collapse
-
#expires_at ⇒ DateTime
readonly
The access url’s expiry time.
-
#identifier ⇒ String
readonly
The url’s indentifier.
-
#key ⇒ BBC::Redux::Key
readonly
The url’s key.
-
#type ⇒ Symbol
readonly
The url’s type.
Instance Method Summary collapse
-
#==(other_url) ⇒ Boolean
(also: #eql?)
True if other_url is a redux url with the same type, identifier and key.
-
#end_point(filename = nil) ⇒ String
(also: #to_s)
Generate the end point to retreive media file.
-
#expired? ⇒ Boolean
True if ttl <= 0, false otherwise.
-
#initialize(identifier, type, key) ⇒ MediaUrl
constructor
A new instance of MediaUrl.
-
#live? ⇒ Boolean
True if ttl > 0, false otherwise.
-
#ttl ⇒ Integer
Url’s time to live in seconds.
Constructor Details
#initialize(identifier, type, key) ⇒ MediaUrl
Returns a new instance of MediaUrl.
89 90 91 92 93 94 95 96 97 98 |
# File 'lib/bbc/redux/media_url.rb', line 89 def initialize( identifier, type, key ) unless TEMPLATES.include?(type) raise UnknownTemplateType.new("Unknown template type #{type}") end @identifier = identifier @type = type @key = key end |
Instance Attribute Details
#expires_at ⇒ DateTime (readonly)
Returns the access url’s expiry time.
|
# File 'lib/bbc/redux/media_url.rb', line 48
|
#identifier ⇒ String (readonly)
Returns the url’s indentifier.
73 74 75 |
# File 'lib/bbc/redux/media_url.rb', line 73 def identifier @identifier end |
#key ⇒ BBC::Redux::Key (readonly)
Returns the url’s key.
82 83 84 |
# File 'lib/bbc/redux/media_url.rb', line 82 def key @key end |
#type ⇒ Symbol (readonly)
Returns the url’s type.
78 79 80 |
# File 'lib/bbc/redux/media_url.rb', line 78 def type @type end |
Instance Method Details
#==(other_url) ⇒ Boolean Also known as: eql?
Returns true if other_url is a redux url with the same type, identifier and key.
114 115 116 |
# File 'lib/bbc/redux/media_url.rb', line 114 def ==(other_url) self.class == other_url.class && self.end_point == other_url.end_point end |
#end_point(filename = nil) ⇒ String Also known as: to_s
Generate the end point to retreive media file
106 107 108 |
# File 'lib/bbc/redux/media_url.rb', line 106 def end_point(filename = nil) EndPoints.send(type, identifier, key.value, filename) end |
#expired? ⇒ Boolean
Returns true if ttl <= 0, false otherwise.
|
# File 'lib/bbc/redux/media_url.rb', line 51
|
#live? ⇒ Boolean
Returns true if ttl > 0, false otherwise.
|
# File 'lib/bbc/redux/media_url.rb', line 56
|
#ttl ⇒ Integer
Returns url’s time to live in seconds.
|
# File 'lib/bbc/redux/media_url.rb', line 61
|