Sha256: d846de473d7287311be064841547ea3701f6fe3f72dde4a6a3c5ad8249a25900

Contents?: true

Size: 1.96 KB

Versions: 1

Compression:

Stored size: 1.96 KB

Contents

class TokyoMetro::App::Renderer::TravelTimeInfo::MetaClass::ThroughOperation::EachType < TokyoMetro::Factory::Decorate::MetaClass

  def initialize( request )
    super( request )
  end

  def render
    h.render inline: <<-HAML , type: :haml , locals: h_locals
%div{ class: :through_operation_info }
  - if train_type.present?
    = train_type.decorate.render_name_box_in_travel_time_info
    %div{ class: :precise }
      = this.render_precise_infos
  - else
    = this.render_precise_infos
    HAML
  end

  def render_precise_infos
    h.render inline: <<-HAML , type: :haml , locals: h_locals
- if from_station.present?
  %p{ class: :from }<
    = "〈" + from_station.name_ja + "から〉"

- if directions.present? or via.present?
  - if directions.present?
    %p{ class: :direction }<
      = directions.map( &:name_ja ).join( "、" ) + "方面"
  - if via.present?
    %p{ class: :via }<
      :ruby
        ary = [ via ].flatten.map( &:name_ja_with_operator_name_precise_and_without_parentheses )
      = ary.join( "、" ) + "経由"

%div{ class: :main }<
  - if railway_line_and_terminal_station_infos.length > 1
    - railway_line_and_terminal_station_infos.each.with_index(1) do | info , i |
      %p
        - if i == railway_line_and_terminal_station_infos.length
          = info.render( suffix: "まで直通運転" )
        - else
          = info.render( suffix: "、" )
  - else
    = railway_line_and_terminal_station_infos.first.render( suffix: "まで直通運転" )

- if note.present?
  %div{ class: :note }<
    = "(" + note.to_s + ")"
    HAML
  end

  private

  def h_locals
    super.merge({
      this: self ,
      train_type: @train_type ,
      from_station: @from_station ,
      directions: directions ,
      via: @via ,
      railway_line_and_terminal_station_infos: [ @railway_line_and_terminal_station_info ].flatten ,
      note: @note
    })
  end

  def directions
    if @direction.present?
      [ @direction ].flatten
    else
      nil
    end
  end

end

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
tokyo_metro-0.10.1 lib/tokyo_metro/app/renderer/travel_time_info/meta_class/through_operation/each_type.rb