Sha256: ca57aa3efa70291c58de3e5824cb9f0ebeda4ab433e7ef2725b80522c8332403

Contents?: true

Size: 691 Bytes

Versions: 1

Compression:

Stored size: 691 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
		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("http://api.kred.com/kredscore?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
				0
			end
		end

	end
end

Version data entries

1 entries across 1 versions & 1 rubygems

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