Class: Kuva::Elements::Photoset

Inherits:
Object
  • Object
show all
Defined in:
lib/kuva/elements/photoset.rb

Instance Attribute Summary collapse

Class Method Summary collapse

Instance Method Summary collapse

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_atObject (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

#descriptionObject (readonly)

Returns the value of attribute description.



5
6
7
# File 'lib/kuva/elements/photoset.rb', line 5

def description
  @description
end

#farmObject (readonly)

Returns the value of attribute farm.



5
6
7
# File 'lib/kuva/elements/photoset.rb', line 5

def farm
  @farm
end

#idObject (readonly)

Returns the value of attribute id.



5
6
7
# File 'lib/kuva/elements/photoset.rb', line 5

def id
  @id
end

#number_of_photosObject (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

#primaryObject (readonly)

Returns the value of attribute primary.



5
6
7
# File 'lib/kuva/elements/photoset.rb', line 5

def primary
  @primary
end

#secretObject (readonly)

Returns the value of attribute secret.



5
6
7
# File 'lib/kuva/elements/photoset.rb', line 5

def secret
  @secret
end

#serverObject (readonly)

Returns the value of attribute server.



5
6
7
# File 'lib/kuva/elements/photoset.rb', line 5

def server
  @server
end

#titleObject (readonly)

Returns the value of attribute title.



5
6
7
# File 'lib/kuva/elements/photoset.rb', line 5

def title
  @title
end

#updated_atObject (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

#viewsObject (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_urlObject



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_photosObject



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