Class: HTTPAttack::Items::StatusNet

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

Overview

Item for the Status.net software (status.net/), which is used by the identi.ca service (identi.ca/).

You can specify the :api_root option to point to a different URL running Status.net (defaults to identi.ca).

Constant Summary collapse

STATS =
['followers_count', 'friends_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 = {}) ⇒ StatusNet

Returns a new instance of StatusNet.

Raises:



12
13
14
15
16
17
18
19
# File 'lib/httpattack/items/status_net.rb', line 12

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

Class Method Details

.descObject



32
33
34
# File 'lib/httpattack/items/status_net.rb', line 32

def desc
  'Open Source microblogging software.'
end

Instance Method Details

#statObject



21
22
23
24
# File 'lib/httpattack/items/status_net.rb', line 21

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

#stats_urlObject



26
27
28
# File 'lib/httpattack/items/status_net.rb', line 26

def stats_url
  URI.parse("http://#{@options[:api_root]}/users/show/#{@username}.json").to_s
end