lib/elevator_simulation/elevator.rb
def goto(request_floor:, destination_floor:)
      time = Time.now.to_f
      @trip_timer = time
      @movement_timer = time
      @request_floor = request_floor
      @destination_floor = destination_floor
      @state = :running
      @direction = (@destination_floor - @current_floor).positive? ? :up : :down

      if distance_from_floor(@request_floor) == 0
        @door_state = :open
        @door_timer = time
      end
    end
# One floor moved per second.
One floor moved per second.
One floor moved per second .
def goto(request_floor:, destination_floor:)
      time = Time.now.to_f
      @trip_timer = time
      @movement_timer = time
      @request_floor = request_floor
      @destination_floor = destination_floor
      @state = :running
      @direction = (@destination_floor - @current_floor).positive? ? :up : :down
      if distance_from_floor(@request_floor) == 0
        @door_state = :open
        @door_timer = time
      end
    end
def goto ( request_floor : , destination_floor : ) time = Time . now . to_f @trip_timer = time @movement_timer = time @request_floor = request_floor @destination_floor = destination_floor @state = :running @direction = ( @destination_floor - @current_floor ) . positive? ? :up : :down if distance_from_floor ( @request_floor ) == 0 @door_state = :open @door_timer = time end end
One floor moved per second.
One floor moved per second .
request_floor
destination_floor