Sha256: d302a0873c71c68384b0b91dc691dfa525d1d53322dd4e11980a08f11c3367c1

Contents?: true

Size: 549 Bytes

Versions: 2

Compression:

Stored size: 549 Bytes

Contents

module Unsplash # :nodoc:

  # Unsplash Search operations
  class Search < Client

    class << self
      # Helper class to facilitate search on multiple classes
      # @param url [String] Url to be searched into
      # @param klass [Class] Class to instantiate the contents with
      # @param params [Hash] Params for the search
      def search(url, klass, params)
        list = JSON.parse(connection.get(url, params).body)

        list["results"].map do |content|
          klass.new content.to_hash
        end
      end
    end
  end
end

Version data entries

2 entries across 2 versions & 1 rubygems

Version Path
unsplash-1.5.0 lib/unsplash/search.rb
unsplash-1.4.3 lib/unsplash/search.rb