Class: Nucleo::Models::MetricPeriodsComparison

Inherits:
Object
  • Object
show all
Includes:
Comparable
Defined in:
lib/nucleo/models/metric_periods_comparison.rb

Instance Method Summary collapse

Constructor Details

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

Creates a new instance of the Metric Periods Comparison domain model.

Parameters:

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


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

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

Instance Method Details

#changeInteger

Returns the percent change

Returns:

  • (Integer)


41
42
43
# File 'lib/nucleo/models/metric_periods_comparison.rb', line 41

def change
  @attributes['change'].to_f
end

#current_valueFloat

Returns the current period value

Returns:

  • (Float)


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

def current_value
  @attributes['current_value'].to_f
end

#dimensionString

Returns the dimension

Returns:

  • (String)


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

def dimension
  @attributes['dimension']
end

#directionString

Returns the direcction of change

Returns:

  • (String)


69
70
71
72
73
74
75
76
77
# File 'lib/nucleo/models/metric_periods_comparison.rb', line 69

def direction
  if self.positive_change?
    'up'
  elsif self.no_change?
    'same'
  elsif self.negative_change?
    'down'
  end
end

#negative_change?Boolean

Returns true if the change is negative

Returns:

  • (Boolean)


62
63
64
# File 'lib/nucleo/models/metric_periods_comparison.rb', line 62

def negative_change?
  self.change < 0
end

#no_change?Boolean

Returns true if there is no change

Returns:

  • (Boolean)


48
49
50
# File 'lib/nucleo/models/metric_periods_comparison.rb', line 48

def no_change?
  self.change == 0
end

#positive_change?Boolean

Returns true if there is a positive change

Returns:

  • (Boolean)


55
56
57
# File 'lib/nucleo/models/metric_periods_comparison.rb', line 55

def positive_change?
  self.change > 0
end

#prior_valueFloat

Returns the prior period value

Returns:

  • (Float)


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

def prior_value
  @attributes['prior_value'].to_f
end