Class: ForemanStatistics::Statistics::CountNumericalFactPair
- Defined in:
- app/services/foreman_statistics/statistics/count_numerical_fact_pair.rb
Instance Attribute Summary collapse
-
#total ⇒ Object
readonly
Returns the value of attribute total.
-
#used ⇒ Object
readonly
Returns the value of attribute used.
Attributes inherited from Base
Instance Method Summary collapse
- #calculate ⇒ Object
-
#initialize(options = {}) ⇒ CountNumericalFactPair
constructor
A new instance of CountNumericalFactPair.
Methods inherited from Base
Constructor Details
#initialize(options = {}) ⇒ CountNumericalFactPair
Returns a new instance of CountNumericalFactPair.
6 7 8 9 10 11 12 13 14 |
# File 'app/services/foreman_statistics/statistics/count_numerical_fact_pair.rb', line 6 def initialize( = {}) super() if @count_by.empty? raise(ArgumentError, 'Must provide :count_by option') end @count_by = @count_by.to_s @total = [:total] || 'size' @used = [:used] || 'free' end |
Instance Attribute Details
#total ⇒ Object (readonly)
Returns the value of attribute total.
4 5 6 |
# File 'app/services/foreman_statistics/statistics/count_numerical_fact_pair.rb', line 4 def total @total end |
#used ⇒ Object (readonly)
Returns the value of attribute used.
4 5 6 |
# File 'app/services/foreman_statistics/statistics/count_numerical_fact_pair.rb', line 4 def used @used end |
Instance Method Details
#calculate ⇒ Object
16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 |
# File 'app/services/foreman_statistics/statistics/count_numerical_fact_pair.rb', line 16 def calculate mem_size = FactValue.(:view_facts).my_facts.mem_average(total_name) mem_free = FactValue.(:view_facts).my_facts.mem_average(used_name) [ { :label => _('free memory'), :data => mem_free }, { :label => _('used memory'), :data => (mem_size - mem_free).round(2) } ] end |