Class: Nucleo::Models::MetricPeriodsTotals

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

Instance Method Summary collapse

Constructor Details

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

Returns an instance of the MetricPeriodsTotals domain model

These are the totals across both ‘current_period` and `prior_period`.

Parameters:

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


12
13
14
# File 'lib/nucleo/models/metric_periods_totals.rb', line 12

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

Instance Method Details

#current_periodNucleo::Models::MetricPeriodTotals

Returns the current period totals



33
34
35
36
37
38
39
40
41
# File 'lib/nucleo/models/metric_periods_totals.rb', line 33

def current_period
  params = {
    'metric'    => self.metric,
    'dimension' => self.dimension,
    'period'    => @attributes['totals']['current_period']
  }

  Nucleo::Models::MetricPeriodTotals.new(params)
end

#dimensionString

Returns the dimension

Returns:

  • (String)


26
27
28
# File 'lib/nucleo/models/metric_periods_totals.rb', line 26

def dimension
  @attributes['dimension']
end

#metricString

Returns the metric type for the totals

Returns:

  • (String)


19
20
21
# File 'lib/nucleo/models/metric_periods_totals.rb', line 19

def metric
  @attributes['metric']
end

#prior_periodNucleo::Models::MetricPeriodTotals Also known as: previous_period

Returns the prior period totals



46
47
48
49
50
51
52
53
54
# File 'lib/nucleo/models/metric_periods_totals.rb', line 46

def prior_period
  params = {
    'metric'    => self.metric,
    'dimension' => self.dimension,
    'period'    => @attributes['totals']['prior_period']
  }

  Nucleo::Models::MetricPeriodTotals.new(params)
end