Sha256: beb626f2460119753b2c7589b0f45aeef2955093dc830b220f04d8f7b43bded9

Contents?: true

Size: 707 Bytes

Versions: 2

Compression:

Stored size: 707 Bytes

Contents

require 'httparty'

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

		##
		# Include httparty module from http querys
		include HTTParty
		base_uri "https://api.peerindex.com/1/actor/topic"
		default_timeout 1

		attr_accessor :data 

		##
		# Initialize and load data from kred api
		def initialize(api_key, username)
			begin
				@data = self.class.get("?twitter_screen_name=#{username}&api_key=#{api_key}", :verify => false)
			rescue Timeout::Error
				@data = false
			end
		end

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

	end
end

Version data entries

2 entries across 2 versions & 1 rubygems

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