Class: Gratitude::Chart

Inherits:
Object
  • Object
show all
Extended by:
Connection
Defined in:
lib/gratitude/chart.rb

Constant Summary collapse

CHARTS =
[]

Instance Attribute Summary collapse

Class Method Summary collapse

Instance Method Summary collapse

Methods included from Connection

faraday

Constructor Details

#initialize(options = {}) ⇒ Chart

Returns a new instance of Chart.



11
12
13
14
15
16
17
18
19
20
# 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

Instance Attribute Details

#active_usersObject (readonly)

Returns the value of attribute active_users.



8
9
10
# File 'lib/gratitude/chart.rb', line 8

def active_users
  @active_users
end

#chargesObject (readonly)

Returns the value of attribute charges.



8
9
10
# File 'lib/gratitude/chart.rb', line 8

def charges
  @charges
end

#dateObject (readonly)

Returns the value of attribute date.



8
9
10
# File 'lib/gratitude/chart.rb', line 8

def date
  @date
end

#total_giftsObject (readonly)

Returns the value of attribute total_gifts.



8
9
10
# File 'lib/gratitude/chart.rb', line 8

def total_gifts
  @total_gifts
end

#total_usersObject (readonly)

Returns the value of attribute total_users.



8
9
10
# File 'lib/gratitude/chart.rb', line 8

def total_users
  @total_users
end

#weekly_giftsObject (readonly)

Returns the value of attribute weekly_gifts.



8
9
10
# File 'lib/gratitude/chart.rb', line 8

def weekly_gifts
  @weekly_gifts
end

#withdrawalsObject (readonly)

Returns the value of attribute withdrawals.



8
9
10
# File 'lib/gratitude/chart.rb', line 8

def withdrawals
  @withdrawals
end

Class Method Details

.allObject



22
23
24
25
# File 'lib/gratitude/chart.rb', line 22

def self.all
  collect_charts if CHARTS.empty?
  CHARTS
end

.newestObject



27
28
29
# File 'lib/gratitude/chart.rb', line 27

def self.newest
  sort_by_date.first
end

.oldestObject



31
32
33
# File 'lib/gratitude/chart.rb', line 31

def self.oldest
  sort_by_date.last
end