Sha256: 6e55db6747fcb1b1650c03ad5a771447898f20330dd92eb12ef7dc57bae4f237

Contents?: true

Size: 1.4 KB

Versions: 4

Compression:

Stored size: 1.4 KB

Contents

require "ykxutils/erubyx"

module Ykxutils
  module Gridlist
    TAMPLETES = { GRID_DEF: { TEMPLATE: %(
    .g-<%= row %>-<%= colum %> {
      grid-row-start: <%= row %>;
      grid-row-end: ,<%= row + 1 %>;
      grid-column-start: <%= colum %>;
      grid-column-end: <%= colum + 1 %>;
    }
    ), OBJ: nil } }.freeze

    module_function

    def make_one_grid(hash, row, colum)
      hash[:OBJ] = Tilt::ErubiTemplate.new { hash[:TEMPLATE] } unless hash[:OBJ]
      hash[:OBJ].render(Object.new, { row: row, colum: colum })
    end

    def make_grid(template_hash, scope, min_row, max_row, min_colum, max_colum)
      (min_row..max_row).map do |row|
        (min_colum..max_colum).map do |colum|
          # puts "#{row} #{colum}"
          value_hash = { row: row, colum: colum }
          # make_one_grid(template_hash, value_hash)
          # p template_hash
          # p value_hash
          Ykxutils::Erubyx.erubi_render(template_hash, scope, value_hash)
        end
      end
    end

    def make_grid_list(min_row, max_row, min_colum, max_colum)
      template_hash = TAMPLETES[:GRID_DEF]
      scope = nil
      make_grid(template_hash, scope, min_row, max_row, min_colum, max_colum)
    end

    def make_grid_list_x(min_row, max_row, min_colum, max_colum)
      template_hash = TAMPLETES[:GRID_DEF]
      scope = nil
      make_grid(template_hash, scope, min_row, max_row, min_colum, max_colum)
    end
  end
end

Version data entries

4 entries across 4 versions & 1 rubygems

Version Path
ykxutils-0.1.14 lib/ykxutils/gridlist.rb
ykxutils-0.1.13 lib/ykxutils/gridlist.rb
ykxutils-0.1.12 lib/ykxutils/gridlist.rb
ykxutils-0.1.11 lib/ykxutils/gridlist.rb