Class: AudioVision::Billboard
- Defined in:
- lib/audio_vision/billboard.rb
Instance Attribute Summary collapse
-
#id ⇒ Object
Returns the value of attribute id.
-
#layout ⇒ Object
Returns the value of attribute layout.
-
#posts ⇒ Object
Returns the value of attribute posts.
-
#published_at ⇒ Object
Returns the value of attribute published_at.
-
#updated_at ⇒ Object
Returns the value of attribute updated_at.
Class Method Summary collapse
- .api_namespace ⇒ Object
-
.current ⇒ Object
Get the current Billboard on AudioVision.
Instance Method Summary collapse
-
#initialize(attributes = {}) ⇒ Billboard
constructor
A new instance of Billboard.
Methods inherited from Base
#==, api_path, collection, find
Constructor Details
#initialize(attributes = {}) ⇒ Billboard
Returns a new instance of Billboard.
35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 |
# File 'lib/audio_vision/billboard.rb', line 35 def initialize(attributes={}) @id = attributes["id"] @layout = attributes["layout"] if attributes["published_at"] @published_at = Time.parse(attributes["published_at"].to_s) end if attributes["updated_at"] @updated_at = Time.parse(attributes["updated_at"].to_s) end @posts = [] Array(attributes["posts"]).each do |json| @posts << AudioVision::Post.new(json) end end |
Instance Attribute Details
#id ⇒ Object
Returns the value of attribute id.
27 28 29 |
# File 'lib/audio_vision/billboard.rb', line 27 def id @id end |
#layout ⇒ Object
Returns the value of attribute layout.
27 28 29 |
# File 'lib/audio_vision/billboard.rb', line 27 def layout @layout end |
#posts ⇒ Object
Returns the value of attribute posts.
27 28 29 |
# File 'lib/audio_vision/billboard.rb', line 27 def posts @posts end |
#published_at ⇒ Object
Returns the value of attribute published_at.
27 28 29 |
# File 'lib/audio_vision/billboard.rb', line 27 def published_at @published_at end |
#updated_at ⇒ Object
Returns the value of attribute updated_at.
27 28 29 |
# File 'lib/audio_vision/billboard.rb', line 27 def updated_at @updated_at end |
Class Method Details
.api_namespace ⇒ Object
5 6 7 |
# File 'lib/audio_vision/billboard.rb', line 5 def api_namespace :billboards end |
.current ⇒ Object
Get the current Billboard on AudioVision. Returns a Billboard if success, otherwise nil.
Example:
AudioVision::Billboard.current #=> #<AudioVision::Billboard>
15 16 17 18 19 20 21 22 23 |
# File 'lib/audio_vision/billboard.rb', line 15 def current response = client.get(endpoint("current")) if response.success? new(response.body) else nil end end |