Sha256: 5bbd3503c78c228fba806c208898f9b96d609e97e16980bdc5674811c1e4491d

Contents?: true

Size: 834 Bytes

Versions: 8

Compression:

Stored size: 834 Bytes

Contents

module Flattr
  class Client
    module Flattrs

      # 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
      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

    end
  end
end

Version data entries

8 entries across 8 versions & 1 rubygems

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