Sha256: 1f684ee100a36215dcef097344ab3918bee79267f8b8a2ac90e80e0c927ae0ca

Contents?: true

Size: 676 Bytes

Versions: 1

Compression:

Stored size: 676 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
		default_timeout 1
		
		attr_accessor :data 

		##
		# Initialize and load data from kred api
		def initialize(api_key, username)
			begin
				@data = self.class.get("https://api.peerindex.com/1/actor/topic?twitter_screen_name=#{username}&api_key=#{api_key}")
			rescue Timeout::Error
				@data = false
			end
		end

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

	end
end

Version data entries

1 entries across 1 versions & 1 rubygems

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