Class: Kuva::Elements::Photo

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

Instance Attribute Summary collapse

Class Method Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(attributes = {}) ⇒ Photo

Returns a new instance of Photo.



7
8
9
10
11
12
13
14
15
16
17
# File 'lib/kuva/elements/photo.rb', line 7

def initialize(attributes = {})
  @id          = attributes.try :id
  @title       = attributes.try :title
  @description = attributes.try :description
  @farm        = attributes.try :farm
  @server      = attributes.try :server
  @secret      = attributes.try :secret
  @is_primary  = attributes.try :is_primary

  self
end

Instance Attribute Details

#descriptionObject (readonly)

Returns the value of attribute description.



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

def description
  @description
end

#farmObject (readonly)

Returns the value of attribute farm.



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

def farm
  @farm
end

#idObject (readonly)

Returns the value of attribute id.



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

def id
  @id
end

#is_primaryObject (readonly)

Returns the value of attribute is_primary.



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

def is_primary
  @is_primary
end

#secretObject (readonly)

Returns the value of attribute secret.



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

def secret
  @secret
end

#serverObject (readonly)

Returns the value of attribute server.



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

def server
  @server
end

#titleObject (readonly)

Returns the value of attribute title.



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

def title
  @title
end

Class Method Details

.find(id) ⇒ Object



19
20
21
22
23
# File 'lib/kuva/elements/photo.rb', line 19

def self.find(id)
  Rails.cache.fetch "photo-#{id}", expires_in: Kuva.cache_expiration do
    new flickr.photos.getInfo(photo_id: id)
  end
end

Instance Method Details

#urlObject



25
26
27
# File 'lib/kuva/elements/photo.rb', line 25

def url
  FlickRaw.url info
end

#url_nObject



29
30
31
# File 'lib/kuva/elements/photo.rb', line 29

def url_n
  FlickRaw.url_n info
end