class BBC::Redux::MediaUrl

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 #

@example Properties of the url object

url = redux_client.asset('5966413090093319525').url(:mp3)

url.expired?   #=> Boolean
url.expires_at #=> DateTime
url.live?      #=> Boolean
url.ttl        #=> Integer
url.end_point  #=> String

@example generate a URL with a different filename

url = redux_client.asset('5966413090093319525').mp3_url

url.end_point('myfile.mp3') #=> String

@author Matt Haynes <matt.haynes@bbc.co.uk>

Constants

TEMPLATES

Known URL templates, these are the only valid options for the type attribute of MediaUrl.initialize. @see MediaUrl#initialize

Attributes

identifier[R]

@!attribute [r] identifier @return [String] the url's indentifier

key[R]

@!attribute [r] key @return [BBC::Redux::Key] the url's key

type[R]

@!attribute [r] type @see MediaUrl.TYPES @return [Symbol] the url's type

Public Class Methods

new( identifier, type, key ) click to toggle source

@param identifier [String] the disk reference or UUID of the asset @param type [Symbol] the transcode type, must be one of MediaUrl.TYPES @param key [BBC::Redux:Key] the key @raise [UnknownTranscodeType] if type parameter is unknown @see MediaUrl.TYPES

# 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

Public Instance Methods

==(other_url) click to toggle source

@return [Boolean] true if other_url is a redux url with the same type,

identifier and key
# 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
Also aliased as: eql?
end_point(filename = nil) click to toggle source

Generate the end point to retreive media file

@param filename [String] an optional filename to specify on the end

point. This can also contain a "%s" template that will be populated
with the MediaUrl#identifier

@return [String] The URL end point

# File lib/bbc/redux/media_url.rb, line 106
def end_point(filename = nil)
  EndPoints.send(type, identifier, key.value, filename)
end
Also aliased as: to_s
eql?(other_url)
Alias for: ==
to_s(filename = nil)
Alias for: end_point