Module: Flattr::Client::Flattrs

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

Instance Method Summary collapse

Instance Method Details

#flattr(thing) ⇒ Object

Public: Flattr a thing

thing - The id or URL of the thing you wan’t to flattr

Examples

f = Flattr.new
f.flattr(450287)
# => true

f = Flattr.new
f.flattr('https://github.com/simon/flattr')
# => true

Returns a true if successful Raises Flattr::Error::Forbidden if your are not allowed to flattr the thing Raises Flattr::Error::NotFound if no thing were found



23
24
25
26
27
28
29
30
# File 'lib/flattr/client/flattrs.rb', line 23

def flattr(thing)
  if thing.is_a?(Fixnum) || !thing.match(/^\d+$/).nil?
    flattr = post("/rest/v2/things/#{thing}/flattr")
  else
    flattr = post("/rest/v2/flattr", {:url => thing})
  end
  return true
end