Class: Nucleo::Models::MetricPeriodsComparison
- Inherits:
-
Object
- Object
- Nucleo::Models::MetricPeriodsComparison
- Includes:
- Comparable
- Defined in:
- lib/nucleo/models/metric_periods_comparison.rb
Instance Method Summary collapse
-
#change ⇒ Integer
Returns the percent change.
-
#current_value ⇒ Float
Returns the current period value.
-
#dimension ⇒ String
Returns the dimension.
-
#direction ⇒ String
Returns the direcction of change.
-
#initialize(attributes = {}) ⇒ Nucleo::Models::MetricPeriodsComparison
constructor
Creates a new instance of the Metric Periods Comparison domain model.
-
#negative_change? ⇒ Boolean
Returns true if the change is negative.
-
#no_change? ⇒ Boolean
Returns true if there is no change.
-
#positive_change? ⇒ Boolean
Returns true if there is a positive change.
-
#prior_value ⇒ Float
Returns the prior period value.
Constructor Details
#initialize(attributes = {}) ⇒ Nucleo::Models::MetricPeriodsComparison
Creates a new instance of the Metric Periods Comparison domain model.
13 14 15 |
# File 'lib/nucleo/models/metric_periods_comparison.rb', line 13 def initialize(attributes={}) @attributes = attributes end |
Instance Method Details
#change ⇒ Integer
Returns the percent change
41 42 43 |
# File 'lib/nucleo/models/metric_periods_comparison.rb', line 41 def change @attributes['change'].to_f end |
#current_value ⇒ Float
Returns the current period value
27 28 29 |
# File 'lib/nucleo/models/metric_periods_comparison.rb', line 27 def current_value @attributes['current_value'].to_f end |
#dimension ⇒ String
Returns the dimension
20 21 22 |
# File 'lib/nucleo/models/metric_periods_comparison.rb', line 20 def dimension @attributes['dimension'] end |
#direction ⇒ String
Returns the direcction of change
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
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
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
55 56 57 |
# File 'lib/nucleo/models/metric_periods_comparison.rb', line 55 def positive_change? self.change > 0 end |
#prior_value ⇒ Float
Returns the prior period value
34 35 36 |
# File 'lib/nucleo/models/metric_periods_comparison.rb', line 34 def prior_value @attributes['prior_value'].to_f end |