Sha256: 405eba276e61e2976ef65de908ab512e2c93cd355e661f16569caf3eab03e64d
Contents?: true
Size: 1.25 KB
Versions: 1
Compression:
Stored size: 1.25 KB
Contents
class TokyoMetro::App::Renderer::WomenOnlyCarInfo < TokyoMetro::Factory::Decorate::MetaClass def initialize( request , railway_lines ) super( request ) @railway_lines = railway_lines set_infos end def render if @infos.present? h.render inline: <<-HAML , type: :haml , locals: h_locals %div{ id: :women_only_car } = ::TokyoMetro::App::Renderer::WomenOnlyCarInfo::Header.new( request ).render - if infos.length > 1 - infos.each do | infos_of_a_railway_line | = infos_of_a_railway_line.render( display_railway_line: true ) - else = infos.first.render HAML end end private def set_infos if @railway_lines.instance_of?( ::RailwayLine ) infos_in_db = ::WomenOnlyCarInfo.where( railway_line_id: @railway_lines.id ) else infos_in_db = ::WomenOnlyCarInfo.where( railway_line_id: @railway_lines.pluck( :id ) ) end @infos = infos_in_db.includes( :operation_day , :from_station_info , :to_station_info ).to_a.group_by( &:railway_line_id ).map { | railway_line_id , infos | ::TokyoMetro::App::Renderer::WomenOnlyCarInfo::EachRailwayLine.new( @request , ::RailwayLine.find( railway_line_id ) , infos ) } end def h_locals super.merge({ infos: @infos }) end end
Version data entries
1 entries across 1 versions & 1 rubygems
Version | Path |
---|---|
tokyo_metro-0.10.1 | lib/tokyo_metro/app/renderer/women_only_car_info.rb |