Module: Toji::Progress::BaseState

Includes:
State
Included in:
KojiState, MoromiState, MotoState
Defined in:
lib/toji/progress/base_state.rb

Constant Summary collapse

KEYS =
[
  :time,
  :elapsed_time,
  :day,
  :day_label,
  :display_time,
  :mark,

  :temps,
  :preset_temp,
  :room_dry_temp,
  :room_wet_temp,
  :room_psychrometry,
  :room_relative_humidity_from_dry_and_wet,
  :room_relative_humidity,
  :room_preset_temp,

  :note,
].freeze

Instance Method Summary collapse

Instance Method Details

#dayObject



34
35
36
# File 'lib/toji/progress/base_state.rb', line 34

def day
  ((elapsed_time_with_offset.to_f + 1) / DAY).ceil
end

#day_labelObject



38
39
40
# File 'lib/toji/progress/base_state.rb', line 38

def day_label
  progress.day_labels[day - 1]
end

#display_time(format = "%m/%d %H:%M") ⇒ Object



42
43
44
# File 'lib/toji/progress/base_state.rb', line 42

def display_time(format="%m/%d %H:%M")
  time.strftime(format)
end

#elapsed_timeObject



26
27
28
# File 'lib/toji/progress/base_state.rb', line 26

def elapsed_time
  time - progress.base_time
end

#elapsed_time_with_offsetObject



30
31
32
# File 'lib/toji/progress/base_state.rb', line 30

def elapsed_time_with_offset
  elapsed_time + progress.day_offset
end

#room_psychrometryObject

乾湿差



55
56
57
58
59
# File 'lib/toji/progress/base_state.rb', line 55

def room_psychrometry
  if room_dry_temp && room_wet_temp
    room_dry_temp.to_f - room_wet_temp.to_f
  end
end

#room_relative_humidity_from_dry_and_wet(swvp: Swvp.default, pressure: 1013, k: 0.000662) ⇒ Object

相対湿度



62
63
64
65
66
67
# File 'lib/toji/progress/base_state.rb', line 62

def room_relative_humidity_from_dry_and_wet(swvp: Swvp.default, pressure: 1013, k: 0.000662)
  if room_dry_temp && room_wet_temp
    psy2rh = PsychrometryToRelativeHumidity.new(swvp: swvp, pressure: pressure, k: k)
    psy2rh.convert(room_wet_temp.to_f, room_dry_temp.to_f)
  end
end