class TokyoMetro::App::Renderer::StationFacility::Platform::Info::MetaClass::TableRow::MetaClass
Public Class Methods
new( request , infos_in_a_row )
click to toggle source
Calls superclass method
# File lib/tokyo_metro/app/renderer/station_facility/platform/info/meta_class/table_row/meta_class.rb, line 3 def initialize( request , infos_in_a_row ) super( request ) @infos_in_a_row = infos_in_a_row set_proc_for_display set_proc_for_dicision end
Public Instance Methods
render()
click to toggle source
# File lib/tokyo_metro/app/renderer/station_facility/platform/info/meta_class/table_row/meta_class.rb, line 11 def render ary = ::Array.new @current_index = 0 while @current_index <= last_index_of_infos_in_a_row info_in_this_cell = @infos_in_a_row[ @current_index ] if info_in_this_cell.blank? ary << nil @current_index += 1 else _number_of_connected_cells = number_of_connected_cells ary << { infos: info_in_this_cell , number_of_connected_cells: number_of_connected_cells , proc_for_display: @proc_for_display } @current_index += _number_of_connected_cells end end h.render inline: <<-HAML , type: :haml , locals: { ary: ary , ul_class: ul_class , li_class: li_class } - ary.each do | element | - if element.blank? = ::StationFacilityPlatformInfoDecorator.render_an_empty_cell - else %td{ class: :present , colspan: element[ :number_of_connected_cells ] }< %ul{ class: ul_class } - element[ :infos ].each do | info | - if li_class.instance_of?( ::Proc ) %li{ class: li_class.call( info ) }< = element[ :proc_for_display ].call( info ) - elsif li_class.string? or li_class.symbol? or ( li_class.instance_of?( ::Array ) and li_class.all?( &:string_or_symbol? ) ) %li{ class: [ li_class ].flatten }< = element[ :proc_for_display ].call( info ) - elsif li_class.blank? = element[ :proc_for_display ].call( info ) HAML end
Private Instance Methods
equal_to_next_cell?( i_compared )
click to toggle source
次のセルと内容が同一か否かを判定するメソッド @note number_of_connected_cells
から呼び出す
# File lib/tokyo_metro/app/renderer/station_facility/platform/info/meta_class/table_row/meta_class.rb, line 79 def equal_to_next_cell?( i_compared ) info_in_i = @infos_in_a_row[ @current_index ] info_compared = @infos_in_a_row[ i_compared ] last_index = @infos_in_a_row.length - 1 if @current_index < last_index and info_compared.present? @proc_for_dicision.call( info_in_i ) == @proc_for_dicision.call( info_compared ) else false end end
last_index_of_infos_in_a_row()
click to toggle source
# File lib/tokyo_metro/app/renderer/station_facility/platform/info/meta_class/table_row/meta_class.rb, line 52 def last_index_of_infos_in_a_row @infos_in_a_row.length - 1 end
li_class()
click to toggle source
# File lib/tokyo_metro/app/renderer/station_facility/platform/info/meta_class/table_row/meta_class.rb, line 94 def li_class raise "Error: The method \'#{ __method__ }\' is not defined yet in this class." end
number_of_connected_cells()
click to toggle source
結合する cell の個数を取得するメソッド
# File lib/tokyo_metro/app/renderer/station_facility/platform/info/meta_class/table_row/meta_class.rb, line 65 def number_of_connected_cells i_next = 1 i_compared = @current_index + i_next while equal_to_next_cell?( i_compared ) i_next += 1 i_compared = @current_index + i_next end i_next end
set_proc_for_dicision()
click to toggle source
# File lib/tokyo_metro/app/renderer/station_facility/platform/info/meta_class/table_row/meta_class.rb, line 60 def set_proc_for_dicision @proc_for_dicision = ::Proc.new { | infos | infos.map( &:id ) } end
set_proc_for_display()
click to toggle source
# File lib/tokyo_metro/app/renderer/station_facility/platform/info/meta_class/table_row/meta_class.rb, line 56 def set_proc_for_display @proc_for_display = ::Proc.new { | info | info.decorate.render } end
ul_class()
click to toggle source
# File lib/tokyo_metro/app/renderer/station_facility/platform/info/meta_class/table_row/meta_class.rb, line 90 def ul_class raise "Error: The method \'#{ __method__ }\' is not defined yet in this class." end