1. module FuelTank
  2. def fill_tank(level)
  3. self.fuel_tank = level
  4. end
  5. def fuel_level
  6. self.fuel_tank
  7. end
  8. protected
  9. attr_accessor :fuel_tank
  10. end
  11. class Car
  12. include FuelTank
  13. attr_reader :current_rpm
  14. @@instances =0
  15. def self.instances
  16. @@instances
  17. end
  18. def self.debug(log)
  19. puts "!!!DEBUG: #{log }!!!!!"
  20. end
  21. debug "start interface"
  22. def initialize
  23. @current_rpm = 0
  24. @@instances += 1
  25. end
  26. def start_engine
  27. start_engine! if engine_stopped?
  28. end
  29. def engine_stopped?
  30. current_rpm.zero?
  31. end
  32. debug " end interface"
  33. protected
  34. attr_writer :current_rpm
  35. def initial_rpm
  36. 700
  37. end
  38. def start_engine!
  39. self.current_rpm =initial_rpm
  40. end
  41. #остановить двигатель
  42. end
  43. class Bike
  44. include FuelTank
  45. end