Class: Nucleo::Models::MetricPeriodTotals
- Inherits:
-
Object
- Object
- Nucleo::Models::MetricPeriodTotals
- Defined in:
- lib/nucleo/models/metric_period_totals.rb
Instance Method Summary collapse
-
#dimension ⇒ Float
Returns the dimension total.
-
#dimension_change ⇒ Float
Returns the dimension change.
-
#dimension_pct_of_site ⇒ Float
(also: #dimension_percent_of_site)
Returns the dimension percentage of site.
-
#dimension_pct_of_site_change ⇒ Float
(also: #dimension_percent_of_site_change)
Returns the dimension percentage of site change.
-
#dimension_percent_of_site_change? ⇒ Boolean
Returns true if there is a dimension percent of site change.
- #dimension_percent_of_site_change_percent ⇒ Object
-
#initialize(attributes = {}) ⇒ Nucleo::Models::MetricPeriodTotals
constructor
Returns an instance of the Metric Period Totals.
-
#metric ⇒ String
Returns the type of metric.
-
#period ⇒ Hash
Returns the period for the totals.
-
#site ⇒ Float
Returns the site total.
-
#site_change ⇒ Float
Returns the site change totals.
-
#site_change? ⇒ Boolean
Returns true if there is a site change.
-
#site_change_percent ⇒ Float
Returns the site change percentage.
Constructor Details
#initialize(attributes = {}) ⇒ Nucleo::Models::MetricPeriodTotals
Returns an instance of the Metric Period Totals
This is specific to the period being returned.
11 12 13 |
# File 'lib/nucleo/models/metric_period_totals.rb', line 11 def initialize(attributes={}) @attributes = attributes end |
Instance Method Details
#dimension ⇒ Float
Returns the dimension total
25 26 27 |
# File 'lib/nucleo/models/metric_period_totals.rb', line 25 def dimension @attributes['dimension'] end |
#dimension_change ⇒ Float
Returns the dimension change
64 65 66 |
# File 'lib/nucleo/models/metric_period_totals.rb', line 64 def dimension_change self.period[translated_key_name(:dimension_change)].to_f end |
#dimension_pct_of_site ⇒ Float Also known as: dimension_percent_of_site
Returns the dimension percentage of site
101 102 103 |
# File 'lib/nucleo/models/metric_period_totals.rb', line 101 def dimension_pct_of_site self.period[translated_key_name(:dimension_pct_of_site)].to_f end |
#dimension_pct_of_site_change ⇒ Float Also known as: dimension_percent_of_site_change
Returns the dimension percentage of site change
78 79 80 |
# File 'lib/nucleo/models/metric_period_totals.rb', line 78 def dimension_pct_of_site_change self.period[translated_key_name(:dimension_pct_of_site_change)].to_f end |
#dimension_percent_of_site_change? ⇒ Boolean
Returns true if there is a dimension percent of site change
86 87 88 |
# File 'lib/nucleo/models/metric_period_totals.rb', line 86 def dimension_percent_of_site_change? self.dimension_percent_of_site_change > 0 end |
#dimension_percent_of_site_change_percent ⇒ Object
90 91 92 93 94 95 96 |
# File 'lib/nucleo/models/metric_period_totals.rb', line 90 def dimension_percent_of_site_change_percent if self.dimension_percent_of_site_change? self.dimension_percent_of_site_change else (self.dimension_percent_of_site * -1) end end |
#metric ⇒ String
Returns the type of metric
18 19 20 |
# File 'lib/nucleo/models/metric_period_totals.rb', line 18 def metric @attributes['metric'] end |
#period ⇒ Hash
Returns the period for the totals
32 33 34 |
# File 'lib/nucleo/models/metric_period_totals.rb', line 32 def period @attributes.fetch('period', {}) end |
#site ⇒ Float
Returns the site total
71 72 73 |
# File 'lib/nucleo/models/metric_period_totals.rb', line 71 def site self.period[translated_key_name(:site)].to_f end |
#site_change ⇒ Float
Returns the site change totals
39 40 41 |
# File 'lib/nucleo/models/metric_period_totals.rb', line 39 def site_change self.period[translated_key_name(:site_change)].to_f end |
#site_change? ⇒ Boolean
Returns true if there is a site change
46 47 48 |
# File 'lib/nucleo/models/metric_period_totals.rb', line 46 def site_change? self.site_change > 0 end |
#site_change_percent ⇒ Float
Returns the site change percentage
53 54 55 56 57 58 59 |
# File 'lib/nucleo/models/metric_period_totals.rb', line 53 def site_change_percent if self.site_change? self.site_change else (self.site_change * -1) end end |