Sha256: 20aba72123e0a4d95a3ea636ccef07cacfffc7c7010927d9a5d244f672b42c47

Contents?: true

Size: 798 Bytes

Versions: 2

Compression:

Stored size: 798 Bytes

Contents

require 'klout'
require 'json'

module Klout
  # Represents a user
  class TwUser
    attr_reader :twitter_id
    
    def initialize(twitter_id)
      @twitter_id = twitter_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
      "/tw-user.json/#{twitter_id}#{action}"
    end
  end
end

Version data entries

2 entries across 2 versions & 1 rubygems

Version Path
klout-3.0.3 lib/klout/twuser.rb
klout-3.0.2 lib/klout/twuser.rb