class Biostars::API::Stats
Statistics as of the Nth day after day-0 (the day of the first ever post) or statistics as of the given date. @author Arian Amador <arian@arianamador.com>
Attributes
@return [Fixnum] total number of answers as of the given day/date.
@return [Fixnum] total number of comments as of the given day/date .
@return [String] the current date, ISO 8601 format
@return [Array] number of new posts in the given day/date .
@return [Array] number of new users in the given day/date .
@return [Array] number of new votes in the given day/date .
@return [Fixnum] total number of questions as of the given day/date.
@return [Fixnum] date, unix epoch time format.
@return [Fixnum] total number of toplevel post as of the given day/date.
@return [Fixnum] total number of users as of the given day/date.
@return [Fixnum] total number of votes as of the given day/date.
Public Class Methods
Statistics as of the given date.
@param year [Fixnum] year to search for @param month [Fixnum] month to search for @param day [Fixnum] day to search for @return [Stats] returns a Stats
object. @raise [Biostars::StatsError] if the variables passed are not valid Fixnum
# File lib/biostars/api/stats.rb, line 101 def self.find_by_date(year=Date.today.year, month=Date.today.month, day=(Date.today.day-1)) raise Biostars::StatsError unless year.is_a?(Fixnum) || month.is_a?(Fixnum) || day.is_a?(Fixnum) url = "stats/date/%s/%s/%s" % [ year, sprintf('%02d', month), sprintf('%02d', day), ] find url end
Statistics as of the Nth day after day-0 (the day of the first ever post).
@param day [Date] number of days after day-0, a number. @return [Stats] returns a Stats
object. @raise [Biostars::StatsError] if the day passed is not a valid Fixnum.
# File lib/biostars/api/stats.rb, line 88 def self.find_by_day(day=Date.today.day) raise Biostars::StatsError, "Expecting a Date Object" unless day.is_a? Fixnum find "stats/day/#{day}" end
Helper method to look up stats for the prior date.
@return [Stats] returns a Stats
object.
# File lib/biostars/api/stats.rb, line 79 def self.latest find_by_date end
Instantiate the Biostars::API::Stats
.
# File lib/biostars/api/stats.rb, line 43 def initialize(attributes) attributes.each do |k,v| instance_variable_set "@#{k}", v unless v.nil? end end
Private Class Methods
Used to call the main HTTParty get but we also don’t want anyone other that the class methods to call it.
# File lib/biostars/api/stats.rb, line 117 def self.find(url) attributes = Biostars::API.get(url) attributes ? new(attributes) : raise(Biostars::StatsError) end