Class: Kuva::Elements::Photoset
- Inherits:
-
Object
- Object
- Kuva::Elements::Photoset
- Defined in:
- lib/kuva/elements/photoset.rb
Instance Attribute Summary collapse
-
#created_at ⇒ Object
readonly
Returns the value of attribute created_at.
-
#description ⇒ Object
readonly
Returns the value of attribute description.
-
#farm ⇒ Object
readonly
Returns the value of attribute farm.
-
#id ⇒ Object
readonly
Returns the value of attribute id.
-
#number_of_photos ⇒ Object
readonly
Returns the value of attribute number_of_photos.
-
#primary ⇒ Object
readonly
Returns the value of attribute primary.
-
#secret ⇒ Object
readonly
Returns the value of attribute secret.
-
#server ⇒ Object
readonly
Returns the value of attribute server.
-
#title ⇒ Object
readonly
Returns the value of attribute title.
-
#updated_at ⇒ Object
readonly
Returns the value of attribute updated_at.
-
#views ⇒ Object
readonly
Returns the value of attribute views.
Class Method Summary collapse
Instance Method Summary collapse
- #image_url ⇒ Object
-
#initialize(attributes = {}) ⇒ Photoset
constructor
A new instance of Photoset.
- #with_photos ⇒ Object
Constructor Details
#initialize(attributes = {}) ⇒ Photoset
Returns a new instance of Photoset.
7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 |
# File 'lib/kuva/elements/photoset.rb', line 7 def initialize(attributes = {}) @id = attributes.try :id @title = attributes.try :title @description = attributes.try :description @views = attributes.try :count_views @number_of_photos = attributes.try :photos @farm = attributes.try :farm @server = attributes.try :server @secret = attributes.try :secret @primary = attributes.try :primary @created_at = attributes.try :date_create @updated_at = attributes.try :date_update self end |
Instance Attribute Details
#created_at ⇒ Object (readonly)
Returns the value of attribute created_at.
5 6 7 |
# File 'lib/kuva/elements/photoset.rb', line 5 def created_at @created_at end |
#description ⇒ Object (readonly)
Returns the value of attribute description.
5 6 7 |
# File 'lib/kuva/elements/photoset.rb', line 5 def description @description end |
#farm ⇒ Object (readonly)
Returns the value of attribute farm.
5 6 7 |
# File 'lib/kuva/elements/photoset.rb', line 5 def farm @farm end |
#id ⇒ Object (readonly)
Returns the value of attribute id.
5 6 7 |
# File 'lib/kuva/elements/photoset.rb', line 5 def id @id end |
#number_of_photos ⇒ Object (readonly)
Returns the value of attribute number_of_photos.
5 6 7 |
# File 'lib/kuva/elements/photoset.rb', line 5 def number_of_photos @number_of_photos end |
#primary ⇒ Object (readonly)
Returns the value of attribute primary.
5 6 7 |
# File 'lib/kuva/elements/photoset.rb', line 5 def primary @primary end |
#secret ⇒ Object (readonly)
Returns the value of attribute secret.
5 6 7 |
# File 'lib/kuva/elements/photoset.rb', line 5 def secret @secret end |
#server ⇒ Object (readonly)
Returns the value of attribute server.
5 6 7 |
# File 'lib/kuva/elements/photoset.rb', line 5 def server @server end |
#title ⇒ Object (readonly)
Returns the value of attribute title.
5 6 7 |
# File 'lib/kuva/elements/photoset.rb', line 5 def title @title end |
#updated_at ⇒ Object (readonly)
Returns the value of attribute updated_at.
5 6 7 |
# File 'lib/kuva/elements/photoset.rb', line 5 def updated_at @updated_at end |
#views ⇒ Object (readonly)
Returns the value of attribute views.
5 6 7 |
# File 'lib/kuva/elements/photoset.rb', line 5 def views @views end |
Class Method Details
.find(id) ⇒ Object
23 24 25 26 27 |
# File 'lib/kuva/elements/photoset.rb', line 23 def self.find(id) Rails.cache.fetch "photoset-#{id}", expires_in: Kuva.cache_expiration do new flickr.photosets.getInfo(photoset_id: id) end end |
Instance Method Details
#image_url ⇒ Object
35 36 37 |
# File 'lib/kuva/elements/photoset.rb', line 35 def image_url FlickRaw.url_q Kuva::Elements::UrlInfo.new primary, farm, server, secret end |
#with_photos ⇒ Object
29 30 31 32 33 |
# File 'lib/kuva/elements/photoset.rb', line 29 def with_photos @with_photos ||= photos.each_with_object([]) do |photo, collection| collection << Kuva::Elements::Photo.new(photo) end end |