Class: DrivingPhysics::Environment

Inherits:
Object
  • Object
show all
Defined in:
lib/driving_physics/environment.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initializeEnvironment

Returns a new instance of Environment.



8
9
10
11
12
13
14
# 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
end

Instance Attribute Details

#air_densityObject

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_tempObject

Returns the value of attribute air_temp.



6
7
8
# File 'lib/driving_physics/environment.rb', line 6

def air_temp
  @air_temp
end

#gObject

Returns the value of attribute g.



6
7
8
# File 'lib/driving_physics/environment.rb', line 6

def g
  @g
end

#hzObject

Returns the value of attribute hz.



5
6
7
# File 'lib/driving_physics/environment.rb', line 5

def hz
  @hz
end

#petrol_densityObject

Returns the value of attribute petrol_density.



6
7
8
# File 'lib/driving_physics/environment.rb', line 6

def petrol_density
  @petrol_density
end

#tickObject (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_sObject



21
22
23
24
25
26
27
# File 'lib/driving_physics/environment.rb', line 21

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