class Nucleo::Models::MetricPeriodTotals
Public Class Methods
new(attributes={})
click to toggle source
Returns an instance of the Metric
Period Totals
This is specific to the period being returned.
@param attributes [Hash]
@return [Nucleo::Models::MetricPeriodTotals]
# File lib/nucleo/models/metric_period_totals.rb, line 11 def initialize(attributes={}) @attributes = attributes end
Public Instance Methods
dimension()
click to toggle source
Returns the dimension
@return [String]
# File lib/nucleo/models/metric_period_totals.rb, line 25 def dimension @attributes['dimension'] end
dimension_change()
click to toggle source
Returns the dimension change
@return [Float]
# 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()
click to toggle source
Returns the dimension percentage of site
@return [Float]
# 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
Also aliased as: dimension_percent_of_site
dimension_pct_of_site_change()
click to toggle source
Returns the dimension percentage of site change
@return [Float]
# 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
Also aliased as: dimension_percent_of_site_change
dimension_percent_of_site_change?()
click to toggle source
Returns true if there is a dimension percent of site change
@return [Boolean]
# 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()
click to toggle source
# 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()
click to toggle source
Returns the type of metric
@return [String]
# File lib/nucleo/models/metric_period_totals.rb, line 18 def metric @attributes['metric'] end
period()
click to toggle source
Returns the period for the totals
@return [Hash]
# File lib/nucleo/models/metric_period_totals.rb, line 32 def period @attributes.fetch('period', {}) end
site()
click to toggle source
Returns the site total
@return [Float]
# File lib/nucleo/models/metric_period_totals.rb, line 71 def site self.period[translated_key_name(:site)].to_f end
site_change()
click to toggle source
Returns the site change totals
@return [Float]
# 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?()
click to toggle source
Returns true if there is a site change
@return [Boolean]
# File lib/nucleo/models/metric_period_totals.rb, line 46 def site_change? self.site_change > 0 end
site_change_percent()
click to toggle source
Returns the site change percentage
@return [Float]
# 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
Private Instance Methods
translated_key_name(key)
click to toggle source
# File lib/nucleo/models/metric_period_totals.rb, line 114 def translated_key_name(key) key = key.to_s [self.metric, key].join('_') end