Class: Legion::Extensions::Agentic::Homeostasis::FossilFuel::Helpers::Combustion
- Inherits:
-
Object
- Object
- Legion::Extensions::Agentic::Homeostasis::FossilFuel::Helpers::Combustion
- Defined in:
- lib/legion/extensions/agentic/homeostasis/fossil_fuel/helpers/combustion.rb
Instance Attribute Summary collapse
-
#burned_at ⇒ Object
readonly
Returns the value of attribute burned_at.
-
#energy_released ⇒ Object
readonly
Returns the value of attribute energy_released.
-
#fuel_amount ⇒ Object
readonly
Returns the value of attribute fuel_amount.
-
#grade ⇒ Object
readonly
Returns the value of attribute grade.
-
#id ⇒ Object
readonly
Returns the value of attribute id.
-
#reserve_id ⇒ Object
readonly
Returns the value of attribute reserve_id.
Instance Method Summary collapse
- #efficient? ⇒ Boolean
- #energy_label ⇒ Object
-
#initialize(reserve_id:, fuel_amount:, grade: :crude, quality: 0.5) ⇒ Combustion
constructor
A new instance of Combustion.
- #to_h ⇒ Object
- #wasteful? ⇒ Boolean
Constructor Details
#initialize(reserve_id:, fuel_amount:, grade: :crude, quality: 0.5) ⇒ Combustion
Returns a new instance of Combustion.
13 14 15 16 17 18 19 20 21 |
# File 'lib/legion/extensions/agentic/homeostasis/fossil_fuel/helpers/combustion.rb', line 13 def initialize(reserve_id:, fuel_amount:, grade: :crude, quality: 0.5) validate_grade!(grade) @id = SecureRandom.uuid @reserve_id = reserve_id @fuel_amount = fuel_amount.to_f.clamp(0.0, 1.0).round(10) @grade = grade.to_sym @energy_released = calculate_energy(fuel_amount, quality) @burned_at = Time.now.utc end |
Instance Attribute Details
#burned_at ⇒ Object (readonly)
Returns the value of attribute burned_at.
10 11 12 |
# File 'lib/legion/extensions/agentic/homeostasis/fossil_fuel/helpers/combustion.rb', line 10 def burned_at @burned_at end |
#energy_released ⇒ Object (readonly)
Returns the value of attribute energy_released.
10 11 12 |
# File 'lib/legion/extensions/agentic/homeostasis/fossil_fuel/helpers/combustion.rb', line 10 def energy_released @energy_released end |
#fuel_amount ⇒ Object (readonly)
Returns the value of attribute fuel_amount.
10 11 12 |
# File 'lib/legion/extensions/agentic/homeostasis/fossil_fuel/helpers/combustion.rb', line 10 def fuel_amount @fuel_amount end |
#grade ⇒ Object (readonly)
Returns the value of attribute grade.
10 11 12 |
# File 'lib/legion/extensions/agentic/homeostasis/fossil_fuel/helpers/combustion.rb', line 10 def grade @grade end |
#id ⇒ Object (readonly)
Returns the value of attribute id.
10 11 12 |
# File 'lib/legion/extensions/agentic/homeostasis/fossil_fuel/helpers/combustion.rb', line 10 def id @id end |
#reserve_id ⇒ Object (readonly)
Returns the value of attribute reserve_id.
10 11 12 |
# File 'lib/legion/extensions/agentic/homeostasis/fossil_fuel/helpers/combustion.rb', line 10 def reserve_id @reserve_id end |
Instance Method Details
#efficient? ⇒ Boolean
23 24 25 |
# File 'lib/legion/extensions/agentic/homeostasis/fossil_fuel/helpers/combustion.rb', line 23 def efficient? @energy_released > (@fuel_amount * 0.7) end |
#energy_label ⇒ Object
31 32 33 |
# File 'lib/legion/extensions/agentic/homeostasis/fossil_fuel/helpers/combustion.rb', line 31 def energy_label Constants.label_for(Constants::ENERGY_LABELS, @energy_released) end |
#to_h ⇒ Object
35 36 37 38 39 40 41 42 43 44 45 46 47 |
# File 'lib/legion/extensions/agentic/homeostasis/fossil_fuel/helpers/combustion.rb', line 35 def to_h { id: @id, reserve_id: @reserve_id, fuel_amount: @fuel_amount, grade: @grade, energy_released: @energy_released, energy_label: energy_label, efficient: efficient?, wasteful: wasteful?, burned_at: @burned_at } end |
#wasteful? ⇒ Boolean
27 28 29 |
# File 'lib/legion/extensions/agentic/homeostasis/fossil_fuel/helpers/combustion.rb', line 27 def wasteful? @energy_released < (@fuel_amount * 0.3) end |