class Gratitude::Chart

Constants

CHARTS

Attributes

active_users[R]
charges[R]
date[R]
total_gifts[R]
total_users[R]
weekly_gifts[R]
withdrawals[R]

Public Class Methods

all() click to toggle source
# File lib/gratitude/chart.rb, line 22
def self.all
  collect_charts if CHARTS.empty?
  CHARTS
end
new(options = {}) click to toggle source
# File lib/gratitude/chart.rb, line 11
def initialize(options = {})
  @active_users = options["active_users"]
  @charges = options["charges"]
  @date = Date.parse(options["date"]) if options["date"]
  @total_gifts = options["total_gifts"]
  @total_users = options["total_users"]
  @weekly_gifts = options["weekly_gifts"]
  @withdrawals = options["withdrawals"]
  CHARTS << self
end
newest() click to toggle source
# File lib/gratitude/chart.rb, line 27
def self.newest
  sort_by_date.first
end
oldest() click to toggle source
# File lib/gratitude/chart.rb, line 31
def self.oldest
  sort_by_date.last
end

Private Class Methods

charts_from_gratipay() click to toggle source
# File lib/gratitude/chart.rb, line 40
def self.charts_from_gratipay
  faraday.get("/about/charts.json").body.to_a
end
collect_charts() click to toggle source
# File lib/gratitude/chart.rb, line 45
def self.collect_charts
  charts_from_gratipay.each { |chart_hash| Chart.new(chart_hash) }
end
sort_by_date() click to toggle source
# File lib/gratitude/chart.rb, line 35
def self.sort_by_date
  all.sort_by(&:date).reverse
end