Class: Nytimes::Movies::MultimediaLink

Inherits:
Object
  • Object
show all
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

Class Method Summary collapse

Instance Method Summary collapse

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

#creditObject (readonly)

Returns the value of attribute credit.



8
9
10
# File 'lib/nytimes/movies/multimedia_link.rb', line 8

def credit
  @credit
end

#heightObject (readonly)

Returns the value of attribute height.



8
9
10
# File 'lib/nytimes/movies/multimedia_link.rb', line 8

def height
  @height
end

#media_typeObject (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

#urlObject (readonly)

Returns the value of attribute url.



8
9
10
# File 'lib/nytimes/movies/multimedia_link.rb', line 8

def url
  @url
end

#widthObject (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