Sha256: 15680438e52b80500ff67b17b9573fd6c91f8662c9b9b1569e2adc603b2f9f84

Contents?: true

Size: 706 Bytes

Versions: 1

Compression:

Stored size: 706 Bytes

Contents

require 'httparty'

##
# This module analize and extract score from social analizer http://kred.com
module Skore
	class Kred 

		##
		# Include httparty module from http querys
		include HTTParty
		base_uri "http://api.kred.com/kredscore"
		default_timeout 1

		attr_accessor :data 

		##
		# Initialize and load data from kred api
		def initialize(app_id, app_key, username)
			begin
				@data = self.class.get("?term=#{username}&source=twitter&app_id=#{app_id}&app_key=#{app_key}")
			rescue Timeout::Error
				@data = false
			end
		end

		##
		# Get score from Kred api
		def score
			if @data
				result = JSON.parse(@data.body)
				result["data"][0]["influence"]
			else
				-1
			end
		end

	end
end

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
skore-0.0.1.pre.1 lib/skore/kred.rb