Class: CO2Equivalents::ResultSet
- Inherits:
-
Hash
- Object
- Hash
- CO2Equivalents::ResultSet
- Defined in:
- lib/co2_equivalents/result_set.rb
Instance Attribute Summary collapse
-
#constraints ⇒ Object
Returns the value of attribute constraints.
-
#kgs_co2 ⇒ Object
Returns the value of attribute kgs_co2.
Class Method Summary collapse
Instance Method Summary collapse
- #compute ⇒ Object
-
#initialize(kgs_co2, *args) ⇒ ResultSet
constructor
A new instance of ResultSet.
Constructor Details
#initialize(kgs_co2, *args) ⇒ ResultSet
Returns a new instance of ResultSet.
11 12 13 14 |
# File 'lib/co2_equivalents/result_set.rb', line 11 def initialize(kgs_co2, *args) self.kgs_co2 = kgs_co2 self.constraints = args end |
Instance Attribute Details
#constraints ⇒ Object
Returns the value of attribute constraints.
9 10 11 |
# File 'lib/co2_equivalents/result_set.rb', line 9 def constraints @constraints end |
#kgs_co2 ⇒ Object
Returns the value of attribute kgs_co2.
9 10 11 |
# File 'lib/co2_equivalents/result_set.rb', line 9 def kgs_co2 @kgs_co2 end |
Class Method Details
.compute(kgs_co2, *args) ⇒ Object
3 4 5 6 7 |
# File 'lib/co2_equivalents/result_set.rb', line 3 def self.compute(kgs_co2, *args) set = new kgs_co2, *args set.compute set end |
Instance Method Details
#compute ⇒ Object
16 17 18 19 20 21 22 |
# File 'lib/co2_equivalents/result_set.rb', line 16 def compute CO2Equivalents.groups.each do |group| group.equivalences.each do |name, equivalent| self[name] = kgs_co2.to_f * equivalent.factor end end end |