Sha256: 07030451bb843924755a9244ab6c912fab566313653b77e5286bb955729bbaa8

Contents?: true

Size: 1.05 KB

Versions: 1

Compression:

Stored size: 1.05 KB

Contents

class TokyoMetro::App::Renderer::StationCode::Normal < TokyoMetro::Factory::Decorate::MetaClass

  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

  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

  private

  def h_locals
    super.merge({
      station_infos: @station_infos ,
      first_info: @first_info
    })
  end

end

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
tokyo_metro-0.10.1 lib/tokyo_metro/app/renderer/station_code/normal.rb