Class: Nucleo::Models::Metric

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

Instance Method Summary collapse

Constructor Details

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

Returns an instance of the Metric domain model. This is the core domain model for a specific metric ‘type` and `classification`.

Parameters:

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


13
14
15
# File 'lib/nucleo/models/metric.rb', line 13

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

Instance Method Details

#classificationString

Returns the classification of the metric

Returns:

  • (String)


20
21
22
# File 'lib/nucleo/models/metric.rb', line 20

def classification
  @attributes['classification']
end

#dimensionString

Returns the dimension

Returns:

  • (String)


34
35
36
# File 'lib/nucleo/models/metric.rb', line 34

def dimension
  @attributes['dimension']
end

#metricString

Returns the type of the metric

Returns:

  • (String)


27
28
29
# File 'lib/nucleo/models/metric.rb', line 27

def metric
  @attributes['metric']
end

#metric_periodsNucleo::Models::MetricPeriods

Returns the metric periods used for comparison



41
42
43
44
45
46
47
48
49
50
51
# File 'lib/nucleo/models/metric.rb', line 41

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

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