Method: HtmlGrid::DivComposite#compose

Defined in:
lib/htmlgrid/divcomposite.rb

#compose(model = @model) ⇒ Object



9
10
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
# File 'lib/htmlgrid/divcomposite.rb', line 9

def compose(model=@model)
  ypos = -1
  xpos = 0
  div = nil
  components.sort_by { |matrix, component|
    [matrix.at(1), matrix.at(0), matrix[2..-1]]
  }.each { |matrix, component|
    if((mpos = matrix.at(1).to_i) > ypos)
      xpos = 0
      ypos = mpos
      div = []
      @grid.push(div)
      css = {}
      if(klass = css_map[ypos])
        css.store('class', klass)
      end
      if(id = css_id_map[ypos])
        css.store('id', id)
      end
      if(style = css_style_map[ypos])
        css.store('style', style)
      end
      @css_grid.push(css.empty? ? nil : css)
    end
    div.push(label(create(component, model), component))
  }
end