Class: Egalite::TableHelper

Inherits:
Object show all
Defined in:
lib/egalite/helper.rb

Class Method Summary collapse

Class Method Details

.table_by_array(header, content, table_opts = {}) ⇒ Object



84
85
86
87
88
# File 'lib/egalite/helper.rb', line 84

def self.table_by_array(header, content, table_opts = {})
  _table(header, content, table_opts) { |line|
    line.map { |s| "<td>#{escape_html(s)}</td>" }.join
  }
end

.table_by_hash(keys, header, content, table_opts = {}) ⇒ Object



75
76
77
78
79
80
81
82
83
# File 'lib/egalite/helper.rb', line 75

def self.table_by_hash(keys, header, content, table_opts = {})
  unless keys.size == header.size
    raise ArgumentError, "key and header count mismatch"
  end

  _table(header, content, table_opts) { |line|
    keys.map { |key| "<td>#{escape_html(line[key])}</td>"}.join
  }
end