Class: Nucleo::Models::MetricPeriodTotals

Inherits:
Object
  • Object
show all
Defined in:
lib/nucleo/models/metric_period_totals.rb

Instance Method Summary collapse

Constructor Details

#initialize(attributes = {}) ⇒ Nucleo::Models::MetricPeriodTotals

Returns an instance of the Metric Period Totals

This is specific to the period being returned.

Parameters:

  • attributes (Hash) (defaults to: {})


11
12
13
# File 'lib/nucleo/models/metric_period_totals.rb', line 11

def initialize(attributes={})
  @attributes = attributes
end

Instance Method Details

#dimensionFloat

Returns the dimension total

Returns:

  • (Float)


25
26
27
# File 'lib/nucleo/models/metric_period_totals.rb', line 25

def dimension
  @attributes['dimension']
end

#dimension_changeFloat

Returns the dimension change

Returns:

  • (Float)


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_siteFloat Also known as: dimension_percent_of_site

Returns the dimension percentage of site

Returns:

  • (Float)


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_changeFloat Also known as: dimension_percent_of_site_change

Returns the dimension percentage of site change

Returns:

  • (Float)


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

Returns:

  • (Boolean)


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_percentObject



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

#metricString

Returns the type of metric

Returns:

  • (String)


18
19
20
# File 'lib/nucleo/models/metric_period_totals.rb', line 18

def metric
  @attributes['metric']
end

#periodHash

Returns the period for the totals

Returns:

  • (Hash)


32
33
34
# File 'lib/nucleo/models/metric_period_totals.rb', line 32

def period
  @attributes.fetch('period', {})
end

#siteFloat

Returns the site total

Returns:

  • (Float)


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_changeFloat

Returns the site change totals

Returns:

  • (Float)


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

Returns:

  • (Boolean)


46
47
48
# File 'lib/nucleo/models/metric_period_totals.rb', line 46

def site_change?
  self.site_change > 0
end

#site_change_percentFloat

Returns the site change percentage

Returns:

  • (Float)


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