Class: RobotCoop

Inherits:
Site
  • Object
show all
Defined in:
lib/tRuTag.rb

Overview

for robot coop sites

Instance Attribute Summary

Attributes inherited from Site

#attrib

Instance Method Summary collapse

Methods inherited from Site

#get_uml, #required_attribute

Constructor Details

#initialize(params) ⇒ RobotCoop

By default the config.xml file uses the text API Key of 1234. Please replace this with your own API Key



308
309
310
311
312
313
314
# File 'lib/tRuTag.rb', line 308

def initialize(params)
	#we could be a number of sites so lets require the truth
	if !params.has_key?('url') || !params.has_key?('sitename') then
		raise ArgumentError,  %{Your RobotCoop site requires a sitename and url attribute}
	end
	super
end

Instance Method Details

#add_tags(tbin) ⇒ Object



316
317
318
319
320
321
322
323
324
325
326
327
328
329
# File 'lib/tRuTag.rb', line 316

def add_tags(tbin)
	require_gem 'r43'
	required_attribute('api_key')
	required_attribute('username')
		
	if @attrib.has_key?('international') && @attrib['international'] != nil
		conn = R43::Connection.new(@attrib['api_key'], @attrib['international'])
	else
		conn = R43::Connection.new(@attrib['api_key'])	
	end 
		
	tags = conn.get_persons_tags(@attrib['username'])
	tags.each { |i| tbin[i.name.downcase] = tbin.fetch(i.name.downcase, 0) + Integer(i.count)}
end