Module: Flattr::Client::Categories

Included in:
Flattr::Client
Defined in:
lib/flattr/client/categories.rb

Instance Method Summary collapse

Instance Method Details

#categoriesObject

Public: Get a list of available categories

Examples

f = Flattr.new
f.categories
# => [Flattr::Category]

Returns a Array with Flattr::Category inside



16
17
18
19
20
# File 'lib/flattr/client/categories.rb', line 16

def categories
  @categories ||= get('/rest/v2/categories').map do |category|
    Flattr::Category.new(category)
  end
end

#category(id) ⇒ Object

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



33
34
35
36
37
# File 'lib/flattr/client/categories.rb', line 33

def category(id)
  categories.select do |category|
    category.id == id
  end.first
end