/
spirzen
/
it-code-examples
Обзор
Документация
Войти
/
spirzen
/
it-code-examples
Код
Запросы
0
Задачи
Вики
Пакеты
0
Релизы
0
Аналитика
Безопасность
master
examples/ruby/ruby-511-102-005/main.rb
21 строка
478 B
Spirzen
Code migration pack
09 июн 2026, 01:41
09 июн 2026, 01:41
cebc284
Код
Авторство
О чём код?
class TemperatureSensor def initialize(initial_temperature) @temperature = initial_temperature @calibration_factor = 1.0 @last_reading_time = nil end def read_temperature @last_reading_time = Time.now @temperature * @calibration_factor end def calibrate(factor) @calibration_factor = factor end end sensor = TemperatureSensor.new(25.5) puts sensor.read_temperature # 25.5 sensor.calibrate(1.05) puts sensor.read_temperature # 26.775