Class: Myflickr::Photo
- Inherits:
-
Struct
- Object
- Struct
- Myflickr::Photo
- Defined in:
- lib/myflickr/photo.rb
Instance Attribute Summary collapse
-
#description ⇒ Object
Returns the value of attribute description.
-
#id ⇒ Object
Returns the value of attribute id.
-
#machine_tags ⇒ Object
Returns the value of attribute machine_tags.
-
#sizes ⇒ Object
readonly
Get the photo sizes for the photo in an array.
-
#tags ⇒ Object
Returns the value of attribute tags.
-
#taken ⇒ Object
Returns the value of attribute taken.
-
#title ⇒ Object
Returns the value of attribute title.
Class Method Summary collapse
-
.find(id) ⇒ Object
Find will grab all sizes of images, process the tags and standard attributes of a photo.
-
.recent ⇒ Object
Get recent photos.
-
.search(search_string) ⇒ Object
Find a collection of photos by text.
-
.search_tags(tags = []) ⇒ Object
Find photos by tag Tags should be an Array.
Instance Attribute Details
#description ⇒ Object
Returns the value of attribute description
2 3 4 |
# File 'lib/myflickr/photo.rb', line 2 def description @description end |
#id ⇒ Object
Returns the value of attribute id
2 3 4 |
# File 'lib/myflickr/photo.rb', line 2 def id @id end |
#machine_tags ⇒ Object
Returns the value of attribute machine_tags
2 3 4 |
# File 'lib/myflickr/photo.rb', line 2 def @machine_tags end |
#sizes ⇒ Object (readonly)
Get the photo sizes for the photo in an array
37 38 39 |
# File 'lib/myflickr/photo.rb', line 37 def sizes @sizes end |
#tags ⇒ Object
Returns the value of attribute tags
2 3 4 |
# File 'lib/myflickr/photo.rb', line 2 def @tags end |
#taken ⇒ Object
Returns the value of attribute taken
2 3 4 |
# File 'lib/myflickr/photo.rb', line 2 def taken @taken end |
#title ⇒ Object
Returns the value of attribute title
2 3 4 |
# File 'lib/myflickr/photo.rb', line 2 def title @title end |
Class Method Details
.find(id) ⇒ Object
Find will grab all sizes of images, process the tags and standard attributes of a photo
22 23 24 25 26 27 28 29 30 31 32 33 34 |
# File 'lib/myflickr/photo.rb', line 22 def self.find(id) photo_call = Query.api_call('flickr.photos.getInfo', "photo_id=#{id}") # Set basic attributes photo = Photo.new(id, *%w(title description).map {|a| (photo_call/a).inner_text }) photo.taken = Time.parse(photo_call.at(:dates)['taken']) # Set tags for photo photo. = (photo_call/"tag[@machine_tag=0]").map{|tag| Tag.new tag['raw'] } photo. = (photo_call/"tag[@machine_tag=1]").map{|tag| MachineTag.from_s tag['raw'] } return photo end |
.recent ⇒ Object
Get recent photos
6 7 8 |
# File 'lib/myflickr/photo.rb', line 6 def self.recent parse(Query.api_call('flickr.photos.search')) end |