Class: DrivingPhysics::Environment
- Inherits:
-
Object
- Object
- DrivingPhysics::Environment
- Defined in:
- lib/driving_physics/environment.rb
Instance Attribute Summary collapse
-
#air_density ⇒ Object
Returns the value of attribute air_density.
-
#air_temp ⇒ Object
Returns the value of attribute air_temp.
-
#g ⇒ Object
Returns the value of attribute g.
-
#hz ⇒ Object
Returns the value of attribute hz.
-
#petrol_density ⇒ Object
Returns the value of attribute petrol_density.
-
#tick ⇒ Object
readonly
Returns the value of attribute tick.
Instance Method Summary collapse
-
#initialize {|_self| ... } ⇒ Environment
constructor
A new instance of Environment.
- #to_s ⇒ Object
Constructor Details
#initialize {|_self| ... } ⇒ Environment
Returns a new instance of Environment.
8 9 10 11 12 13 14 15 16 |
# File 'lib/driving_physics/environment.rb', line 8 def initialize self.hz = HZ @g = G @air_temp = AIR_TEMP @air_density = AIR_DENSITY @petrol_density = PETROL_DENSITY yield self if block_given? end |
Instance Attribute Details
#air_density ⇒ Object
Returns the value of attribute air_density.
6 7 8 |
# File 'lib/driving_physics/environment.rb', line 6 def air_density @air_density end |
#air_temp ⇒ Object
Returns the value of attribute air_temp.
6 7 8 |
# File 'lib/driving_physics/environment.rb', line 6 def air_temp @air_temp end |
#g ⇒ Object
Returns the value of attribute g.
6 7 8 |
# File 'lib/driving_physics/environment.rb', line 6 def g @g end |
#hz ⇒ Object
Returns the value of attribute hz.
5 6 7 |
# File 'lib/driving_physics/environment.rb', line 5 def hz @hz end |
#petrol_density ⇒ Object
Returns the value of attribute petrol_density.
6 7 8 |
# File 'lib/driving_physics/environment.rb', line 6 def petrol_density @petrol_density end |
#tick ⇒ Object (readonly)
Returns the value of attribute tick.
5 6 7 |
# File 'lib/driving_physics/environment.rb', line 5 def tick @tick end |
Instance Method Details
#to_s ⇒ Object
23 24 25 26 27 28 29 |
# File 'lib/driving_physics/environment.rb', line 23 def to_s [format("Tick: %d Hz", @hz), format("G: %.2f m/s^2", @g), format("Air: %.1f C %.2f kg/m^3", @air_temp, @air_density), format("Petrol: %.2f kg/L", @petrol_density), ].join(" | ") end |