Class: AudioVision::Post
Instance Attribute Summary collapse
-
#assets ⇒ Object
Returns the value of attribute assets.
-
#attributions ⇒ Object
Returns the value of attribute attributions.
-
#body ⇒ Object
Returns the value of attribute body.
-
#byline ⇒ Object
Returns the value of attribute byline.
-
#category ⇒ Object
Returns the value of attribute category.
-
#id ⇒ Object
Returns the value of attribute id.
-
#public_url ⇒ Object
Returns the value of attribute public_url.
-
#published_at ⇒ Object
Returns the value of attribute published_at.
-
#teaser ⇒ Object
Returns the value of attribute teaser.
-
#thumbnail ⇒ Object
Returns the value of attribute thumbnail.
-
#title ⇒ Object
Returns the value of attribute title.
Class Method Summary collapse
- .api_namespace ⇒ Object
-
.find_by_url(url) ⇒ Object
Find a Post by its URL.
Instance Method Summary collapse
-
#initialize(attributes = {}) ⇒ Post
constructor
A new instance of Post.
Methods inherited from Base
#==, api_path, collection, find
Constructor Details
#initialize(attributes = {}) ⇒ Post
Returns a new instance of Post.
45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 |
# File 'lib/audio_vision/post.rb', line 45 def initialize(attributes={}) @id = attributes["id"] @title = attributes["title"] @teaser = attributes["teaser"] @body = attributes["body"] @thumbnail = attributes["thumbnail"] @byline = attributes["byline"] @public_url = attributes["public_url"] if attributes["category"] @category = Category.new(attributes["category"]) end if attributes["published_at"] @published_at = Time.parse(attributes["published_at"].to_s) end @attributions = [] Array(attributes["attributions"]).each do |json| @attributions << Attribution.new(json) end @assets = [] Array(attributes["assets"]).each do |json| @assets << Asset.new(json) end end |
Instance Attribute Details
#assets ⇒ Object
Returns the value of attribute assets.
31 32 33 |
# File 'lib/audio_vision/post.rb', line 31 def assets @assets end |
#attributions ⇒ Object
Returns the value of attribute attributions.
31 32 33 |
# File 'lib/audio_vision/post.rb', line 31 def attributions @attributions end |
#body ⇒ Object
Returns the value of attribute body.
31 32 33 |
# File 'lib/audio_vision/post.rb', line 31 def body @body end |
#byline ⇒ Object
Returns the value of attribute byline.
31 32 33 |
# File 'lib/audio_vision/post.rb', line 31 def @byline end |
#category ⇒ Object
Returns the value of attribute category.
31 32 33 |
# File 'lib/audio_vision/post.rb', line 31 def category @category end |
#id ⇒ Object
Returns the value of attribute id.
31 32 33 |
# File 'lib/audio_vision/post.rb', line 31 def id @id end |
#public_url ⇒ Object
Returns the value of attribute public_url.
31 32 33 |
# File 'lib/audio_vision/post.rb', line 31 def public_url @public_url end |
#published_at ⇒ Object
Returns the value of attribute published_at.
31 32 33 |
# File 'lib/audio_vision/post.rb', line 31 def published_at @published_at end |
#teaser ⇒ Object
Returns the value of attribute teaser.
31 32 33 |
# File 'lib/audio_vision/post.rb', line 31 def @teaser end |
#thumbnail ⇒ Object
Returns the value of attribute thumbnail.
31 32 33 |
# File 'lib/audio_vision/post.rb', line 31 def thumbnail @thumbnail end |
#title ⇒ Object
Returns the value of attribute title.
31 32 33 |
# File 'lib/audio_vision/post.rb', line 31 def title @title end |
Class Method Details
.api_namespace ⇒ Object
5 6 7 |
# File 'lib/audio_vision/post.rb', line 5 def api_namespace :posts end |
.find_by_url(url) ⇒ Object
Find a Post by its URL. Returns a Post if success, otherwise nil.
Example:
AudioVision::Post.find_by_url(
"http://audiovision.scpr.org/321/the-night-watch"
)
#=> #<AudioVision::Post>
19 20 21 22 23 24 25 26 27 |
# File 'lib/audio_vision/post.rb', line 19 def find_by_url(url) response = client.get(endpoint("by_url"), :url => url) if response.success? new(response.body) else nil end end |