Class: TokyoMetro::App::Renderer::StationFacility::Platform::Info::MetaClass::EachDirection

Inherits:
Factory::Decorate::MetaClass
  • Object
show all
Includes:
Common
Defined in:
lib/tokyo_metro/app/renderer/station_facility/platform/info/meta_class/each_direction.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Methods included from Common

#barrier_free_facility_infos, #car_composition_types, #has_barrier_free_facility_infos?, #has_one_car_composition_type?, #has_railway_direction_infos?, #has_surrounding_area_infos?, #has_transfer_infos?, #max_car_composition, #railway_line_css_class_name, #railway_line_name_en, #railway_line_name_ja, #surrounding_area_infos, #tab_name, #transfer_infos

Constructor Details

#initialize(request, platform_infos, railway_lines, railway_direction) ⇒ EachDirection

Returns a new instance of EachDirection.



3
4
5
6
7
8
# File 'lib/tokyo_metro/app/renderer/station_facility/platform/info/meta_class/each_direction.rb', line 3

def initialize( request , platform_infos , railway_lines , railway_direction )
  super( request )
  @platform_infos = platform_infos.sort_by( &:car_number )
  set_railway_line( railway_lines )
  @railway_direction = railway_direction
end

Instance Attribute Details

#platform_infosObject (readonly)

Returns the value of attribute platform_infos.



10
11
12
# File 'lib/tokyo_metro/app/renderer/station_facility/platform/info/meta_class/each_direction.rb', line 10

def platform_infos
  @platform_infos
end

#railway_directionObject (readonly)

Returns the value of attribute railway_direction.



11
12
13
# File 'lib/tokyo_metro/app/renderer/station_facility/platform/info/meta_class/each_direction.rb', line 11

def railway_direction
  @railway_direction
end

Instance Method Details

#renderObject



15
16
17
18
19
20
21
22
# File 'lib/tokyo_metro/app/renderer/station_facility/platform/info/meta_class/each_direction.rb', line 15

def render
  if has_transfer_infos? or has_barrier_free_facility_infos? or has_surrounding_area_infos?
    h.render inline: <<-HAML , type: :haml , locals: h_locals
= info.render_direction_info
= info.render_infos_of_each_platform
    HAML
  end
end

#render_barrier_free_facility_infosObject



79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
# File 'lib/tokyo_metro/app/renderer/station_facility/platform/info/meta_class/each_direction.rb', line 79

def render_barrier_free_facility_infos
  if has_barrier_free_facility_infos?
    _barrier_free_facility_infos = barrier_free_facility_infos
    hl = {
      request: request ,
      inside: _barrier_free_facility_infos.map { | infos_of_each_car | infos_of_each_car.select( &:inside? ) } ,
      outside: _barrier_free_facility_infos.map { | infos_of_each_car | infos_of_each_car.select( &:outside? ) }
    }

    h.render inline: <<-HAML , type: :haml , locals: hl
- if inside.any?( &:present? )
%tr{ class: :barrier_free_infos_inside }
  = ::StationFacilityPlatformInfoDecorator.render_inside_barrier_free_facility_title
  = ::TokyoMetro::App::Renderer::StationFacility::Platform::Info::MetaClass::TableRow::BarrierFreeFacilityInfos::Inside.new( request , inside ).render

- if outside.any?( &:present? )
%tr{ class: :barrier_free_infos_outside }
  = ::StationFacilityPlatformInfoDecorator.render_outside_barrier_free_facility_title
  = ::TokyoMetro::App::Renderer::StationFacility::Platform::Info::MetaClass::TableRow::BarrierFreeFacilityInfos::Outside.new( request , outside ).render
    HAML
  end
end

#render_car_number_array_if_one_car_composition_typeObject



55
56
57
58
59
60
61
62
63
# File 'lib/tokyo_metro/app/renderer/station_facility/platform/info/meta_class/each_direction.rb', line 55

def render_car_number_array_if_one_car_composition_type
  h.render inline: <<-HAML , type: :haml , locals: h_locals
%tr{ class: [ info.railway_line_css_class_name , :car_numbers , :text_en ] }
= ::StationFacilityPlatformInfoDecorator.render_an_empty_cell
- ( 1..( info.max_car_composition ) ).each do | n |
  %td{ class: :car_number }<
    = n
  HAML
end

#render_direction_infoObject



24
25
26
27
28
29
30
31
32
33
34
35
# File 'lib/tokyo_metro/app/renderer/station_facility/platform/info/meta_class/each_direction.rb', line 24

def render_direction_info
  if @railway_direction.present?
    h.render inline: <<-HAML , type: :haml , locals: { railway_direction: @railway_direction }
%div{ class: :info_of_railway_direction }
%div{ class: :title_of_direction }
  %h4{ class: :text_ja }<
    = railway_direction.station_info.decorate.render_name_ja( with_subname: true , suffix: "方面行きホーム" )
  %h5{ class: :text_en }<
    = railway_direction.station_info.decorate.render_name_en( with_subname: true , prefix: "Platform for " )
    HAML
  end
end

#render_infos_of_each_platformObject



37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
# File 'lib/tokyo_metro/app/renderer/station_facility/platform/info/meta_class/each_direction.rb', line 37

def render_infos_of_each_platform
  if has_one_car_composition_type?
    h.render inline: <<-HAML , type: :haml , locals: { this: self }
%table{ class: :platform_info }
= this.render_car_number_array_if_one_car_composition_type
- # 乗換路線がある場合は、乗換の情報を記述
= this.render_transfer_infos
- # 駅構内の施設がある場合は、駅構内の施設の情報を記述
= this.render_barrier_free_facility_infos
- # 駅周辺の情報がある場合は、駅周辺の情報を記述
= this.render_surrounding_area_infos
    HAML
  else
    # h.platform_infos_of_each_platform( @platform_infos , railway_line_css_class_name , car_composition_types , has_transfer_infos? , has_barrier_free_facility_infos? , has_surrounding_area_infos? )
    raise "Error"
  end
end

#render_surrounding_area_infosObject



102
103
104
105
106
107
108
109
110
111
112
113
114
# File 'lib/tokyo_metro/app/renderer/station_facility/platform/info/meta_class/each_direction.rb', line 102

def render_surrounding_area_infos
  if has_surrounding_area_infos?
    hl = {
      request: request ,
      surrounding_area_infos: surrounding_area_infos
    }
    h.render inline: <<-HAML , type: :haml , locals: hl
%tr{ class: :surrounding_areas }
= ::StationFacilityPlatformInfoDecorator.render_surrounding_area_info_title
= ::TokyoMetro::App::Renderer::StationFacility::Platform::Info::MetaClass::TableRow::SurroundingAreaInfos.new( request , surrounding_area_infos ).render
    HAML
  end
end

#render_transfer_infosObject



65
66
67
68
69
70
71
72
73
74
75
76
77
# File 'lib/tokyo_metro/app/renderer/station_facility/platform/info/meta_class/each_direction.rb', line 65

def render_transfer_infos
  if has_transfer_infos?
    hl = {
      request: request ,
      transfer_infos: transfer_infos
    }
    h.render inline: <<-HAML , type: :haml , locals: hl
%tr{ class: :transfer_infos }
= ::StationFacilityPlatformInfoDecorator.render_transfer_info_title
= ::TokyoMetro::App::Renderer::StationFacility::Platform::Info::MetaClass::TableRow::TransferInfos.new( request , transfer_infos ).render
    HAML
  end
end