Sha256: 2e7308e34e6616f710ff56bd1296f9a8888258ba33e144718179a97a87f4be37

Contents?: true

Size: 783 Bytes

Versions: 4

Compression:

Stored size: 783 Bytes

Contents

require 'klout'
require 'json'

module Klout
  # Represents a user
  class User
    attr_reader :klout_id
    
    def initialize(klout_id)
      @klout_id = klout_id
    end
    
    def details
      response = get
      Hashie::Mash.new(response)
    end
    
    def score
      response = get "score"
      Hashie::Mash.new(response)
    end
    
    def topics
      response = get "topics"
      response.parsed_response
    end
    
    def influence
      response = get "influence"
      Hashie::Mash.new(response)
    end
    
    private
    
    def get(action = nil)
      Klout.get uri_for(action), :query => {key: Klout.api_key}
    end
    
    def uri_for(action = nil)
      action = "/#{action}" if action
      "/user.json/#{klout_id}#{action}"
    end
  end
end

Version data entries

4 entries across 4 versions & 1 rubygems

Version Path
klout-3.0.3 lib/klout/user.rb
klout-3.0.2 lib/klout/user.rb
klout-3.0.1 lib/klout/user.rb
klout-3.0.0 lib/klout/user.rb