Class: Almicube::Bundler::DaysAgoBundler
- Defined in:
- lib/almicube/bundler/days_ago_bundler.rb
Direct Known Subclasses
Instance Attribute Summary collapse
-
#range ⇒ Object
readonly
Returns the value of attribute range.
Attributes inherited from Base
Attributes included from Cog
Instance Method Summary collapse
-
#initialize(options = {}) ⇒ DaysAgoBundler
constructor
A new instance of DaysAgoBundler.
- #keys ⇒ Object
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(={}) @range = ( [:range] || 1 ).to_i [:name] ||= :"#{range}-days-ago" super end |
Instance Attribute Details
#range ⇒ Object (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
#keys ⇒ Object
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 |