Class: Blackbeard::GroupMetric
Instance Attribute Summary collapse
Instance Method Summary
collapse
Methods included from Chartable
#recent_days, #recent_days_chart, #recent_hours, #recent_hours_chart
#config, #db, #guest_method, included, #tz
Constructor Details
#initialize(group, metric) ⇒ GroupMetric
Returns a new instance of GroupMetric.
8
9
10
11
|
# File 'lib/blackbeard/group_metric.rb', line 8
def initialize(group, metric)
@group = group
@metric = metric
end
|
Instance Attribute Details
#group ⇒ Object
Returns the value of attribute group.
6
7
8
|
# File 'lib/blackbeard/group_metric.rb', line 6
def group
@group
end
|
#metric ⇒ Object
Returns the value of attribute metric.
6
7
8
|
# File 'lib/blackbeard/group_metric.rb', line 6
def metric
@metric
end
|
Instance Method Details
#add(context, amount) ⇒ Object
17
18
19
20
21
|
# File 'lib/blackbeard/group_metric.rb', line 17
def add(context, amount)
uid = context.unique_identifier
segment = group.segment_for(context)
metric_data.add(uid, amount, segment) unless segment.nil?
end
|
#chartable_result_for_day(date) ⇒ Object
35
36
37
|
# File 'lib/blackbeard/group_metric.rb', line 35
def chartable_result_for_day(date)
metric_data.result_for_day(date)
end
|
#chartable_result_for_hour(hour) ⇒ Object
31
32
33
|
# File 'lib/blackbeard/group_metric.rb', line 31
def chartable_result_for_hour(hour)
metric_data.result_for_hour(hour)
end
|
#chartable_segments ⇒ Object
27
28
29
|
# File 'lib/blackbeard/group_metric.rb', line 27
def chartable_segments
group.segments
end
|
#metric_data ⇒ Object
23
24
25
|
# File 'lib/blackbeard/group_metric.rb', line 23
def metric_data
@metric_data ||= MetricData.const_get(type.capitalize).new(metric, group, nil)
end
|
#type ⇒ Object
13
14
15
|
# File 'lib/blackbeard/group_metric.rb', line 13
def type
metric.type
end
|