Sha256: d6bee8fc6aa04cba4867efa7ba725d42b1c7e18475e08095ec32994879c2db7f

Contents?: true

Size: 871 Bytes

Versions: 9

Compression:

Stored size: 871 Bytes

Contents

require 'flattr/category'

module Flattr
  class Client
    module Categories

      # Public: Get a list of available categories
      #
      # Examples
      #
      #   f = Flattr.new
      #   f.categories
      #   # => [Flattr::Category]
      #
      # Returns a Array with Flattr::Category inside
      def categories
        @categories ||= get('/rest/v2/categories').map do |category|
          Flattr::Category.new(category)
        end
      end

      # Public: Get a category by id
      #
      # id - id of the catgory
      #
      # Examples
      #
      #   f = Flattr.new
      #   f.category("software")
      #   # => Flattr::Category
      #
      # Returns a Flattr::Category on success and nil on failure
      def category(id)
        categories.select do |category|
          category.id == id
        end.first
      end


    end
  end
end

Version data entries

9 entries across 9 versions & 1 rubygems

Version Path
flattr-0.3.7 lib/flattr/client/categories.rb
flattr-0.3.6 lib/flattr/client/categories.rb
flattr-0.3.5 lib/flattr/client/categories.rb
flattr-0.3.4 lib/flattr/client/categories.rb
flattr-0.3.3 lib/flattr/client/categories.rb
flattr-0.3.2 lib/flattr/client/categories.rb
flattr-0.3.1 lib/flattr/client/categories.rb
flattr-0.3.0 lib/flattr/client/categories.rb
flattr-0.2.3 lib/flattr/client/categories.rb