Class: Nucleo::Models::MetricPeriodRow
- Inherits:
-
Object
- Object
- Nucleo::Models::MetricPeriodRow
- Defined in:
- lib/nucleo/models/metric_period_row.rb
Instance Method Summary collapse
-
#change ⇒ Float
Returns the change.
-
#current? ⇒ Boolean
Returns true if this is the current period.
-
#dimension ⇒ String
Returns the dimension.
-
#dimension_name ⇒ String
Returns the dimension name.
-
#initialize(attributes = {}) ⇒ Nucleo::Models::MetricPeriodRow
constructor
Returns an instance of the Metric Period Row domain model.
-
#metric ⇒ String
Returns the type of the row.
-
#page ⇒ Nucleo::Models::Page
Returns an instance of the Page domain model.
-
#page? ⇒ Boolean
Returns true if there is a page.
-
#pct_total ⇒ Float
(also: #percent_total)
Returns the percent total.
-
#period_name ⇒ String
Returns the period name.
-
#prior? ⇒ Boolean
Returns true if this is the prior period.
-
#rank ⇒ Integer
Returns the rank.
-
#rank_change ⇒ Integer
Returns the rank change.
-
#value ⇒ Integer
Return the value for this metric.
Constructor Details
#initialize(attributes = {}) ⇒ Nucleo::Models::MetricPeriodRow
Returns an instance of the Metric Period Row domain model
9 10 11 |
# File 'lib/nucleo/models/metric_period_row.rb', line 9 def initialize(attributes={}) @attributes = attributes end |
Instance Method Details
#change ⇒ Float
Returns the change
87 88 89 |
# File 'lib/nucleo/models/metric_period_row.rb', line 87 def change row[translated_key_name(:change)].to_f end |
#current? ⇒ Boolean
Returns true if this is the current period
48 49 50 |
# File 'lib/nucleo/models/metric_period_row.rb', line 48 def current? 'current' == self.period_name end |
#dimension ⇒ String
Returns the dimension
23 24 25 |
# File 'lib/nucleo/models/metric_period_row.rb', line 23 def dimension @attributes['dimension'] end |
#dimension_name ⇒ String
Returns the dimension name
30 31 32 33 34 35 36 |
# File 'lib/nucleo/models/metric_period_row.rb', line 30 def dimension_name if self.page? self.page.title else row.fetch(self.dimension, '') end end |
#metric ⇒ String
Returns the type of the row
16 17 18 |
# File 'lib/nucleo/models/metric_period_row.rb', line 16 def metric @attributes['metric'] end |
#page ⇒ Nucleo::Models::Page
Returns an instance of the Page domain model
62 63 64 65 66 67 68 |
# File 'lib/nucleo/models/metric_period_row.rb', line 62 def page val = row['page'] return nil if val.nil? || val.empty? Nucleo::Models::Page.new(val) end |
#page? ⇒ Boolean
Returns true if there is a page
73 74 75 |
# File 'lib/nucleo/models/metric_period_row.rb', line 73 def page? !self.page.nil? end |
#pct_total ⇒ Float Also known as: percent_total
Returns the percent total
94 95 96 |
# File 'lib/nucleo/models/metric_period_row.rb', line 94 def pct_total row[translated_key_name(:pct_total)].to_f end |
#period_name ⇒ String
Returns the period name
41 42 43 |
# File 'lib/nucleo/models/metric_period_row.rb', line 41 def period_name @attributes['period_name'] end |
#prior? ⇒ Boolean
Returns true if this is the prior period
55 56 57 |
# File 'lib/nucleo/models/metric_period_row.rb', line 55 def prior? 'prior' == self.period_name end |
#rank ⇒ Integer
Returns the rank
109 110 111 |
# File 'lib/nucleo/models/metric_period_row.rb', line 109 def rank row[translated_key_name(:rank)].to_i end |
#rank_change ⇒ Integer
Returns the rank change
102 103 104 |
# File 'lib/nucleo/models/metric_period_row.rb', line 102 def rank_change row[translated_key_name(:rank_change)].to_i end |
#value ⇒ Integer
Return the value for this metric
80 81 82 |
# File 'lib/nucleo/models/metric_period_row.rb', line 80 def value row.fetch(self.metric, 0).to_i end |