Class: Nytimes::Movies::Link
- Inherits:
-
Object
- Object
- Nytimes::Movies::Link
- 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
-
#link_type ⇒ Object
readonly
Returns the value of attribute link_type.
-
#suggested_text ⇒ Object
readonly
Returns the value of attribute suggested_text.
-
#url ⇒ Object
readonly
Returns the value of attribute url.
Class Method Summary collapse
-
.create_from_api(hash = {}) ⇒ Object
Create a Link object from a hash snippet returned from the API.
Instance Method Summary collapse
-
#initialize(hash = {}) ⇒ Link
constructor
A new instance of Link.
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
#link_type ⇒ Object (readonly)
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_text ⇒ Object (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 |
#url ⇒ Object (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 |