Class: HTTPAttack::Items::Github

Inherits:
Base
  • Object
show all
Defined in:
lib/httpattack/items/github.rb

Constant Summary collapse

STATS =
['followers_count', 'following_count']

Instance Attribute Summary

Attributes inherited from Base

#stats

Class Method Summary collapse

Instance Method Summary collapse

Methods inherited from Base

name, #reload_stats, #reload_stats!

Constructor Details

#initialize(username, options = {}) ⇒ Github

Returns a new instance of Github.

Raises:



7
8
9
10
11
12
# File 'lib/httpattack/items/github.rb', line 7

def initialize(username, options = {})
  options[:remote_stat] ||= 'followers_count'
  raise Items::InvalidStat unless STATS.include?(options[:remote_stat])
  @username = username
  @remote_stat = options[:remote_stat]
end

Class Method Details

.descObject



25
26
27
# File 'lib/httpattack/items/github.rb', line 25

def desc
  'The social power of code.'
end

Instance Method Details

#statObject



14
15
16
17
# File 'lib/httpattack/items/github.rb', line 14

def stat
  self.reload_stats! unless stats
  stats['user'][@remote_stat].to_i
end

#stats_urlObject



19
20
21
# File 'lib/httpattack/items/github.rb', line 19

def stats_url
  URI.parse("http://github.com/api/v2/json/user/show/#{@username}").to_s
end