class Nucleo::Models::MetricPeriods

Public Class Methods

new(attributes={}) click to toggle source

Returns an instance of the Metric Periods domain models

This takes in the `totals`, `current_period`, and `prior_period` and wraps their response bodies in specific objects for comparisons.

@param attributes [Hash]

@return [Nucleo::Models::MetricPeriods]

# File lib/nucleo/models/metric_periods.rb, line 15
def initialize(attributes={})
  @attributes = attributes
end

Public Instance Methods

current_period() click to toggle source

Returns the metric period

@return [Nucleo::Models::MetricPeriod]

# File lib/nucleo/models/metric_periods.rb, line 56
def current_period
  params = @attributes.fetch('current_period', {}).merge!('metric' => self.metric, 'dimension' => self.dimension, 'period_name' => 'current')
  Nucleo::Models::MetricPeriod.new(params)
end
dimension() click to toggle source

Returns the dimension

@return [String]

# File lib/nucleo/models/metric_periods.rb, line 36
def dimension
  @attributes['dimension']
end
metric() click to toggle source

Returns the type of the metric

@return [String]

# File lib/nucleo/models/metric_periods.rb, line 29
def metric
  @attributes['metric']
end
periods_comparisons() click to toggle source

Returns a metric periods comparisons collection domain model

@return [Array]

# File lib/nucleo/models/metric_periods.rb, line 73
def periods_comparisons
  Nucleo::Models::MetricPeriodsComparisons.new(self.current_period, self.prior_period)
end
previous_period()
Alias for: prior_period
prior_period() click to toggle source

Returns the prior metric period

@return [Nucleo::Models::MetricPeriod]

# File lib/nucleo/models/metric_periods.rb, line 64
def prior_period
  params = @attributes.fetch('prior_period', {}).merge!('metric' => self.metric, 'dimension' => self.dimension, 'period_name' => 'prior')
  Nucleo::Models::MetricPeriod.new(params)
end
Also aliased as: previous_period
totals() click to toggle source

Returns the metric period totals

@return [Nucleo::Models::MetricPeriodTotals]

# File lib/nucleo/models/metric_periods.rb, line 43
def totals
  params = {
    'metric'    => self.metric,
    'dimension' => self.dimension,
    'totals'    => @attributes['totals']
  }

  Nucleo::Models::MetricPeriodsTotals.new(params)
end
type() click to toggle source

Returns the type of metric for period

@return [String]

# File lib/nucleo/models/metric_periods.rb, line 22
def type
  @attributes['type']
end