Class: Afterburn::ListMetric
- Inherits:
-
Object
- Object
- Afterburn::ListMetric
- Includes:
- Redis::Objects
- Defined in:
- lib/afterburn/list_metric.rb
Instance Attribute Summary collapse
-
#timestamp ⇒ Object
readonly
Returns the value of attribute timestamp.
Class Method Summary collapse
- .for_list(list, timestamps) ⇒ Object
- .for_timestamp(lists, timestamp) ⇒ Object
-
.timestamp_count_vector(list, timestamps) ⇒ Object
TODO test.
Instance Method Summary collapse
- #count! ⇒ Object
- #id ⇒ Object
-
#initialize(list, timestamp = Time.now) ⇒ ListMetric
constructor
A new instance of ListMetric.
Constructor Details
#initialize(list, timestamp = Time.now) ⇒ ListMetric
Returns a new instance of ListMetric.
25 26 27 28 |
# File 'lib/afterburn/list_metric.rb', line 25 def initialize(list, = Time.now) @list = list @timestamp = end |
Instance Attribute Details
#timestamp ⇒ Object (readonly)
Returns the value of attribute timestamp.
9 10 11 |
# File 'lib/afterburn/list_metric.rb', line 9 def @timestamp end |
Class Method Details
.for_list(list, timestamps) ⇒ Object
16 17 18 |
# File 'lib/afterburn/list_metric.rb', line 16 def self.for_list(list, ) .map { || new(list, ) } end |
.for_timestamp(lists, timestamp) ⇒ Object
12 13 14 |
# File 'lib/afterburn/list_metric.rb', line 12 def self.(lists, ) lists.map { |list| new(list, ) } end |
.timestamp_count_vector(list, timestamps) ⇒ Object
TODO test
21 22 23 |
# File 'lib/afterburn/list_metric.rb', line 21 def self.(list, ) Vector[*for_list(list, ).map { |metric| metric.card_count.to_i }] end |
Instance Method Details
#count! ⇒ Object
34 35 36 |
# File 'lib/afterburn/list_metric.rb', line 34 def count! card_count.incr(@list.card_count) end |
#id ⇒ Object
30 31 32 |
# File 'lib/afterburn/list_metric.rb', line 30 def id @id ||= Base64.encode64("#{@list.id}:#{@timestamp.to_i}") end |