Skip to content

Commit a77d223

Browse files
committed
refactor: 変数名を意味的に明確化
- span → duration: イベントの継続時間を表す適切な名前に変更 - start_slot/end_slot → slot_start/slot_end: 命名パターンを統一 - start_minutes/end_minutes → event_start/event_end: イベントの時間であることを明確化 他、細かな cosmetic change など。
1 parent 95dd2f0 commit a77d223

File tree

2 files changed

+20
-21
lines changed

2 files changed

+20
-21
lines changed

_pages/time-table.html

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -61,8 +61,8 @@ <h2 class="text-4xl text-center mb-8">
6161
{% assign accent = event.accent | default: room.style.color | default: '#c43b3b' %}
6262

6363
<td class="ttable__cell ttable__cell--event"
64-
rowspan="{{ event.span }}"
65-
style="--span: {{ event.span }};">
64+
rowspan="{{ event.duration }}"
65+
style="--span: {{ event.duration }};">
6666
<div class="ttable__event" style="--accent: {{ accent }};">
6767
<div class="ttable__event-time" >{{ event.start }}–{{ event.end }}</div>
6868
<div class="ttable__event-title">{{ event.title }}</div>

_plugins/time_table_generator.rb

Lines changed: 18 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -19,12 +19,12 @@ def generate(site)
1919
return unless tt
2020

2121
# 設定値を取得
22-
slot_minutes = tt.fetch('slot_minutes', DEFAULT_SLOT_MINUTES)
22+
slot_minutes = tt.fetch('slot_minutes', DEFAULT_SLOT_MINUTES)
2323
day_start = tt.fetch('day_start_hour', DEFAULT_DAY_START_HOUR)
24-
day_end = tt.fetch('day_end_hour', DEFAULT_DAY_END_HOUR)
25-
rooms = tt.fetch('rooms', [])
26-
events = tt.fetch('events', [])
27-
room_styles = tt.fetch('room_styles', {})
24+
day_end = tt.fetch('day_end_hour', DEFAULT_DAY_END_HOUR)
25+
rooms = tt.fetch('rooms', [])
26+
events = tt.fetch('events', [])
27+
room_styles = tt.fetch('room_styles', {})
2828

2929
# イベント情報を表形式で生成
3030
time_table_events = create_event_table(events, rooms, room_styles, slot_minutes, day_start, day_end)
@@ -47,7 +47,7 @@ def create_event_table(events, rooms, room_styles, slot_minutes, day_start, day_
4747
# ルーム情報を生成(room.style でアクセス可能)
4848
rooms_data = rooms.map do |room_name|
4949
{
50-
'name' => room_name,
50+
'name' => room_name,
5151
'style' => room_styles[room_name] || {}
5252
}
5353
end
@@ -64,31 +64,30 @@ def create_event_table(events, rooms, room_styles, slot_minutes, day_start, day_
6464
'rooms' => rooms_data,
6565
'time_labels' => time_labels,
6666
'total_slots' => total_slots - 1, # Liquidの (0..n) は inclusive なので -1
67-
'total_rooms' => rooms.size - 1 # Liquidの (0..n) は inclusive なので -1
67+
'total_rooms' => rooms.size - 1, # Liquidの (0..n) は inclusive なので -1
6868
}
6969
end
7070

7171
def place_event(event, table, rooms, slot_minutes, day_start, total_slots)
7272
room_index = rooms.index(event['room'])
7373
return unless room_index
7474

75-
# 時間を分に変換
76-
start_minutes = time_to_minutes(event['start'])
77-
end_minutes = time_to_minutes(event['end'])
75+
# 時間を分に変換して揃える
76+
event_start = time_to_minutes(event['start'])
77+
event_end = time_to_minutes(event['end'])
7878

79-
# スロット計算
80-
start_slot = [(start_minutes - day_start * 60) / slot_minutes, 0].max.to_i
81-
end_slot = [(end_minutes - day_start * 60) / slot_minutes, total_slots].min.to_i
82-
span = end_slot - start_slot
79+
# スロット計算(分に揃える)
80+
slot_start = [(event_start - day_start * 60) / slot_minutes, 0].max.to_i
81+
slot_end = [(event_end - day_start * 60) / slot_minutes, total_slots].min.to_i
82+
duration = slot_end - slot_start
8383

84-
return if start_slot >= total_slots || span <= 0
84+
return if slot_start >= total_slots || duration <= 0
8585

86-
# Eventにspan情報を追加
87-
enhanced_event = event.merge('span' => span)
88-
table[start_slot][room_index] = enhanced_event
86+
# イベントの長さ情報 (duration) を追加
87+
table[slot_start][room_index] = event.merge('duration' => duration)
8988

9089
# 継続スロットをマーク
91-
(start_slot + 1...end_slot).each do |slot|
90+
(slot_start + 1...slot_end).each do |slot|
9291
break if slot >= total_slots
9392
table[slot][room_index] = 'continued'
9493
end

0 commit comments

Comments
 (0)