public
Description: A small, yet powerful, gem to interface with Flickr photostreams
Homepage: http://sneaq.net/tag/fleakr
Clone URL: git://github.com/reagent/fleakr.git
fleakr / lib / fleakr / objects / search.rb
100644 30 lines (25 sloc) 0.688 kb
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
module Fleakr
  module Objects # :nodoc:
    class Search
 
      # Create a new search
      def initialize(search_options)
        @search_options = search_options
      end
 
      # Retrieve search results from the API
      def results
        @results ||= begin
          response = Fleakr::Api::MethodRequest.with_response!('photos.search', parameters)
          (response.body/'rsp/photos/photo').map {|p| Photo.new(p) }
        end
      end
 
      private
      def tag_list
        Array(@search_options[:tags]).join(',')
      end
 
      def parameters
        @search_options.merge!(:tags => tag_list) if tag_list.length > 0
        @search_options
      end
 
    end
  end
end