Class: Extractors::Base
- Inherits:
-
Object
- Object
- Extractors::Base
- Defined in:
- lib/prosperity/extractors/base.rb
Instance Attribute Summary collapse
-
#end_time ⇒ Object
readonly
Returns the value of attribute end_time.
-
#metric ⇒ Object
readonly
Returns the value of attribute metric.
-
#option ⇒ Object
readonly
Returns the value of attribute option.
-
#period ⇒ Object
readonly
Returns the value of attribute period.
-
#start_time ⇒ Object
readonly
Returns the value of attribute start_time.
Instance Method Summary collapse
- #aggregate ⇒ Object
-
#initialize(metric, option, start_time, end_time, period) ⇒ Base
constructor
A new instance of Base.
- #key ⇒ Object
- #label ⇒ Object
- #scope ⇒ Object
- #uid ⇒ Object
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_time ⇒ Object (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 |
#metric ⇒ Object (readonly)
Returns the value of attribute metric.
3 4 5 |
# File 'lib/prosperity/extractors/base.rb', line 3 def metric @metric end |
#option ⇒ Object (readonly)
Returns the value of attribute option.
3 4 5 |
# File 'lib/prosperity/extractors/base.rb', line 3 def option @option end |
#period ⇒ Object (readonly)
Returns the value of attribute period.
3 4 5 |
# File 'lib/prosperity/extractors/base.rb', line 3 def period @period end |
#start_time ⇒ Object (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
#aggregate ⇒ Object
26 27 28 |
# File 'lib/prosperity/extractors/base.rb', line 26 def aggregate metric.aggregate end |
#key ⇒ Object
14 15 16 |
# File 'lib/prosperity/extractors/base.rb', line 14 def key self.class.key end |
#label ⇒ Object
22 23 24 |
# File 'lib/prosperity/extractors/base.rb', line 22 def label "#{metric.title} by #{key} with option #{option}" end |
#scope ⇒ Object
10 11 12 |
# File 'lib/prosperity/extractors/base.rb', line 10 def scope @metric..fetch(option).block.call(metric.scope) end |
#uid ⇒ Object
18 19 20 |
# File 'lib/prosperity/extractors/base.rb', line 18 def uid "#{@metric.to_s.underscore}_#{@option}_#{key}" end |