Class: TokyoMetro::App::Renderer::StationFacility::Platform::Info::MetaClass::TableRow::MetaClass

Inherits:
Factory::Decorate::MetaClass
  • Object
show all
Defined in:
lib/tokyo_metro/app/renderer/station_facility/platform/info/meta_class/table_row/meta_class.rb

Instance Method Summary collapse

Constructor Details

#initialize(request, infos_in_a_row) ⇒ MetaClass

Returns a new instance of MetaClass.



3
4
5
6
7
8
9
# 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

Instance Method Details

#renderObject



11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
# 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