Class: Almicube::Bundler::DaysAgoBundler

Inherits:
Base
  • Object
show all
Defined in:
lib/almicube/bundler/days_ago_bundler.rb

Direct Known Subclasses

WeeklyBundler

Instance Attribute Summary collapse

Attributes inherited from Base

#name

Attributes included from Cog

#ranking

Instance Method Summary collapse

Methods included from Cog

#active?, #after_aggregate, #before_aggregate

Constructor Details

#initialize(options = {}) ⇒ DaysAgoBundler

Returns a new instance of DaysAgoBundler.



6
7
8
9
10
# File 'lib/almicube/bundler/days_ago_bundler.rb', line 6

def initialize(options={})
  @range = ( options[:range] || 1 ).to_i
  options[:name] ||= :"#{range}-days-ago"
  super options
end

Instance Attribute Details

#rangeObject (readonly)

Returns the value of attribute range.



4
5
6
# File 'lib/almicube/bundler/days_ago_bundler.rb', line 4

def range
  @range
end

Instance Method Details

#keysObject



12
13
14
15
16
17
18
19
# File 'lib/almicube/bundler/days_ago_bundler.rb', line 12

def keys
  return [] unless has_ranking?
  range.times.map do |i|
    key = ranking.data_key
    key[:date] = key[:date] - (i+1).days
    key
  end
end