blob: a7607f7a02538ed2abe89ac254a93424e66aa865 (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
|
module TimeTablesHelper
def bounding_info(time_table)
return t('time_tables.time_table.empty') if time_table.bounding_dates.empty?
t('time_tables.time_table.bounding',
:start => l(time_table.bounding_dates.min),
:end => l(time_table.bounding_dates.max))
end
def bounding_short_info(dates)
return t('time_tables.time_table.empty') if dates.empty?
"#{l(dates.min)} #{l(dates.max)}"
end
def time_table_bounding( time_table)
bounding_short_info( time_table.bounding_dates)
end
def time_tables_shortest_info( vehicle)
bounding_short_info( vehicle.bounding_dates)
end
def time_tables_info( vehicle)
vehicle.time_tables.map do |time_table|
"#{time_table_bounding( time_table)} - #{composition_info(time_table)}"
end.join( "\n")
end
def composition_info(time_table)
return if time_table.bounding_dates.empty?
if time_table.dates.empty?
t('time_tables.time_table.periods_count', :count => time_table.periods.count)
elsif time_table.periods.empty?
t('time_tables.time_table.dates_count', :count => time_table.dates.count)
else
t('time_tables.time_table.periods_dates_count',
:dates_count => time_table.dates.count,
:periods_count => time_table.periods.count)
end
end
end
|