Class: Nytimes::Movies::Link

Inherits:
Object
  • Object
show all
Defined in:
lib/nytimes/movies/link.rb

Overview

Represents a link returned from the Reviews API. Each link has a URL, suggested text, and a link_type which gives you some idea of what the remote target of the link is. Possible link types include: FIXME

Instance Attribute Summary collapse

Class Method Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(hash = {}) ⇒ Link

Returns a new instance of Link.



11
12
13
14
15
# File 'lib/nytimes/movies/link.rb', line 11

def initialize(hash={})
	@url = hash[:url]
	@link_type = hash[:link_type]
	@suggested_text = hash[:suggested_text]
end

Instance Attribute Details

Returns the value of attribute link_type.



9
10
11
# File 'lib/nytimes/movies/link.rb', line 9

def link_type
  @link_type
end

#suggested_textObject (readonly)

Returns the value of attribute suggested_text.



9
10
11
# File 'lib/nytimes/movies/link.rb', line 9

def suggested_text
  @suggested_text
end

#urlObject (readonly)

Returns the value of attribute url.



9
10
11
# File 'lib/nytimes/movies/link.rb', line 9

def url
  @url
end

Class Method Details

.create_from_api(hash = {}) ⇒ Object

Create a Link object from a hash snippet returned from the API. You should never need to call this.



19
20
21
# File 'lib/nytimes/movies/link.rb', line 19

def self.create_from_api(hash={})
	Link.new :url => hash['url'], :link_type => hash['type'], :suggested_text => hash['suggested_link_text']
end