Class: Nytimes::Movies::MultimediaLink
- Inherits:
-
Object
- Object
- Nytimes::Movies::MultimediaLink
- Defined in:
- lib/nytimes/movies/multimedia_link.rb
Overview
Represents a link to a multimedia asset from the New York Times. Invariably these are images or thumbnails, but it could also be expanded to include movies or sound. The following attributes are part of the link. FIXME
Instance Attribute Summary collapse
-
#credit ⇒ Object
readonly
Returns the value of attribute credit.
-
#height ⇒ Object
readonly
Returns the value of attribute height.
-
#media_type ⇒ Object
readonly
Returns the value of attribute media_type.
-
#url ⇒ Object
readonly
Returns the value of attribute url.
-
#width ⇒ Object
readonly
Returns the value of attribute width.
Class Method Summary collapse
-
.create_from_api(hash = {}) ⇒ Object
Create a MultimediaLink object from a hash snippet returned from the API.
Instance Method Summary collapse
-
#initialize(hash = {}) ⇒ MultimediaLink
constructor
A new instance of MultimediaLink.
Constructor Details
#initialize(hash = {}) ⇒ MultimediaLink
Returns a new instance of MultimediaLink.
11 12 13 14 15 |
# File 'lib/nytimes/movies/multimedia_link.rb', line 11 def initialize(hash={}) hash.each_pair do |k,v| instance_variable_set("@#{k}", v) end end |
Instance Attribute Details
#credit ⇒ Object (readonly)
Returns the value of attribute credit.
8 9 10 |
# File 'lib/nytimes/movies/multimedia_link.rb', line 8 def credit @credit end |
#height ⇒ Object (readonly)
Returns the value of attribute height.
8 9 10 |
# File 'lib/nytimes/movies/multimedia_link.rb', line 8 def height @height end |
#media_type ⇒ Object (readonly)
Returns the value of attribute media_type.
8 9 10 |
# File 'lib/nytimes/movies/multimedia_link.rb', line 8 def media_type @media_type end |
#url ⇒ Object (readonly)
Returns the value of attribute url.
8 9 10 |
# File 'lib/nytimes/movies/multimedia_link.rb', line 8 def url @url end |
#width ⇒ Object (readonly)
Returns the value of attribute width.
8 9 10 |
# File 'lib/nytimes/movies/multimedia_link.rb', line 8 def width @width end |
Class Method Details
.create_from_api(hash = {}) ⇒ Object
Create a MultimediaLink object from a hash snippet returned from the API. You should never need to call this.
19 20 21 22 23 24 25 26 27 |
# File 'lib/nytimes/movies/multimedia_link.rb', line 19 def self.create_from_api(hash={}) return nil if hash.nil? || hash.empty? if hash.key? 'resource' hash = hash['resource'] end new(:media_type => hash['type'], :url => hash['src'], :height => hash['height'], :width => hash['width'], :credit => hash['credit']) end |