Class: Extractors::Base

Inherits:
Object
  • Object
show all
Defined in:
lib/prosperity/extractors/base.rb

Direct Known Subclasses

Change, Interval, Total

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(metric, option, start_time, end_time, period) ⇒ Base

Returns a new instance of Base.



5
6
7
8
# File 'lib/prosperity/extractors/base.rb', line 5

def initialize(metric, option, start_time, end_time, period)
  @metric, @option, @start_time, @end_time, @period =
    metric, option, period.floor_date.call(start_time), period.ceil_date.call(end_time), period
end

Instance Attribute Details

#end_timeObject (readonly)

Returns the value of attribute end_time.



3
4
5
# File 'lib/prosperity/extractors/base.rb', line 3

def end_time
  @end_time
end

#metricObject (readonly)

Returns the value of attribute metric.



3
4
5
# File 'lib/prosperity/extractors/base.rb', line 3

def metric
  @metric
end

#optionObject (readonly)

Returns the value of attribute option.



3
4
5
# File 'lib/prosperity/extractors/base.rb', line 3

def option
  @option
end

#periodObject (readonly)

Returns the value of attribute period.



3
4
5
# File 'lib/prosperity/extractors/base.rb', line 3

def period
  @period
end

#start_timeObject (readonly)

Returns the value of attribute start_time.



3
4
5
# File 'lib/prosperity/extractors/base.rb', line 3

def start_time
  @start_time
end

Instance Method Details

#aggregateObject



26
27
28
# File 'lib/prosperity/extractors/base.rb', line 26

def aggregate
  metric.aggregate
end

#keyObject



14
15
16
# File 'lib/prosperity/extractors/base.rb', line 14

def key
  self.class.key
end

#labelObject



22
23
24
# File 'lib/prosperity/extractors/base.rb', line 22

def label
  "#{metric.title} by #{key} with option #{option}"
end

#scopeObject



10
11
12
# File 'lib/prosperity/extractors/base.rb', line 10

def scope
  @metric.options.fetch(option).block.call(metric.scope)
end

#uidObject



18
19
20
# File 'lib/prosperity/extractors/base.rb', line 18

def uid
  "#{@metric.to_s.underscore}_#{@option}_#{key}"
end