Class: Myflickr::Set

Inherits:
Struct
  • Object
show all
Defined in:
lib/myflickr/set.rb

Instance Attribute Summary collapse

Class Method Summary collapse

Instance Method Summary collapse

Instance Attribute Details

#descriptionObject

Returns the value of attribute description

Returns:

  • (Object)

    the current value of description



2
3
4
# File 'lib/myflickr/set.rb', line 2

def description
  @description
end

#idObject

Returns the value of attribute id

Returns:

  • (Object)

    the current value of id



2
3
4
# File 'lib/myflickr/set.rb', line 2

def id
  @id
end

#photo_countObject

Returns the value of attribute photo_count

Returns:

  • (Object)

    the current value of photo_count



2
3
4
# File 'lib/myflickr/set.rb', line 2

def photo_count
  @photo_count
end

#titleObject

Returns the value of attribute title

Returns:

  • (Object)

    the current value of title



2
3
4
# File 'lib/myflickr/set.rb', line 2

def title
  @title
end

Class Method Details

.find(id) ⇒ Object

Get information regarding set by searching with the set’s ID



9
10
11
# File 'lib/myflickr/set.rb', line 9

def self.find id
  parse(Query.api_call('flickr.photosets.getInfo', "photoset_id=#{id}"))[0]
end

.listObject

Get a list of available photosets



4
5
6
# File 'lib/myflickr/set.rb', line 4

def self.list
  parse(Query.api_call('flickr.photosets.getList'))
end

Instance Method Details

#machine_tagsObject

Return a list of machine_tags for the set (This is rough as guts as far as queries go) Queries: > photosets.getPhotos (1 call) > Photo.find ID (n calls)



41
42
43
44
45
46
47
48
49
# File 'lib/myflickr/set.rb', line 41

def machine_tags
  tags = []
  photos.each do |photo|
    photo.machine_tags.each do |tag|
      tags << tag
    end
  end
  tags.uniq
end

#photosObject

Get the photos within a set Queries: > photosets.getPhotos (1 call) > Photo.find ID (n calls)



17
18
19
20
21
# File 'lib/myflickr/set.rb', line 17

def photos
  (Query.api_call('flickr.photosets.getPhotos', "photoset_id=#{id}")/:photo).map do |photo|
    Photo.find photo[:id]
  end
end

#similarObject

Search for photos that may tags that the current set collectivly owns from its photos’ tags. Then search for those photos within sets, return an array of sets or an empty array



53
54
55
56
57
58
59
# File 'lib/myflickr/set.rb', line 53

def similar
  sets = []
  Set.list.each do |set|
    sets << set unless (self.tags & set.tags).empty? or set == self
  end
  sets.uniq
end

#tagsObject

Return a list of tags for the set (This is rough as guts as far as queries go) Queries: > photosets.getPhotos (1 call) > Photo.find ID (n calls)



27
28
29
30
31
32
33
34
35
# File 'lib/myflickr/set.rb', line 27

def tags
  tags = []
  photos.each do |photo|
    photo.tags.each do |tag|
      tags << tag[:value]
    end
  end
  tags.uniq
end