Sha256: 407b60bf0a985d115be4b7a8bae73aa17eba621ae4ea98c720fabd3ff366fc54

Contents?: true

Size: 1.17 KB

Versions: 1

Compression:

Stored size: 1.17 KB

Contents

class TokyoMetro::Factory::Decorate::Api::TrainLocation::List::EachDirection < TokyoMetro::Factory::Decorate::MetaClass

  def initialize( request , railway_line , railway_direction_in_api_same_as , train_location_infos )
    super( request )
    @railway_line = railway_line
    @railway_direction = ::RailwayDirection.find_by( railway_line: @railway_line , in_api_same_as: railway_direction_in_api_same_as )
    unless @railway_direction.present?
      raise "\[Error\] railway_line: #{ @railway_line.same_as } / railway_direction: #{ railway_direction_in_api_same_as }"
    end
    @train_location_infos = train_location_infos
  end

  attr_reader :railway_direction

  def render
    h.render inline: <<-HAML , type: :haml , locals: h_locals
= railway_direction.decorate.render_title_in_train_location
%ul{ class: [ :train_locations_of_each_direction , :clearfix ] }
  - train_location_infos.each do | train_location |
    = train_location.decorate( request , railway_line ).render
    HAML
  end

  private

  def h_locals
    super.merge({
      railway_line: @railway_line ,
      railway_direction: @railway_direction ,
      train_location_infos: @train_location_infos
    })
  end

end

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
tokyo_metro-0.10.1 lib/tokyo_metro/factory/decorate/api/train_location/list/each_direction.rb