Sha256: b0822f0b7eefaf73c8397520d57e4f79d488a88d3d2346e45d1ce36d94bcb230

Contents?: true

Size: 724 Bytes

Versions: 2

Compression:

Stored size: 724 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}", :verify => false)
			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

2 entries across 2 versions & 1 rubygems

Version Path
skore-0.0.3 lib/skore/kred.rb
skore-0.0.2 lib/skore/kred.rb