Class: TokyoMetro::App::Renderer::StationCode::Normal

Inherits:
Factory::Decorate::MetaClass show all
Defined in:
lib/tokyo_metro/app/renderer/station_code/normal.rb

Instance Method Summary collapse

Constructor Details

#initialize(request, station_infos, first_info: nil) ⇒ Normal

Returns a new instance of Normal.



3
4
5
6
7
8
9
10
11
# File 'lib/tokyo_metro/app/renderer/station_code/normal.rb', line 3

def initialize( request , station_infos , first_info: nil )
  super( request )
  @station_infos = [ station_infos ].flatten

  if @station_infos.all?( &:at_ayase? ) or @station_infos.all?( &:at_nakano_sakaue? )
    @station_infos = [ @station_infos.first ]
  end
  @first_info = first_info
end

Instance Method Details

#renderObject



13
14
15
16
17
18
19
20
21
22
23
24
25
26
# File 'lib/tokyo_metro/app/renderer/station_code/normal.rb', line 13

def render
  h.render inline: <<-HAML , type: :haml , locals: h_locals
%div{ class: :station_codes }<
- if first_info.present?
  = first_info.decorate.render_each_station_code_image_tag
  - other_station_infos = station_infos.select { | info | info.id != first_info.id }
  - if other_station_infos.present?
    - other_station_infos.each do | info |
      = info.decorate.render_each_station_code_image_tag
- else
  - station_infos.each do | info |
    = info.decorate.render_each_station_code_image_tag
  HAML
end