Sha256: 418530d8cf356cb521a1c045b2b98d0f22b48602038cf11db6b131d1baf720d8

Contents?: true

Size: 796 Bytes

Versions: 56

Compression:

Stored size: 796 Bytes

Contents

# encoding: utf-8

# Hash
class Hash
  # get html table string from key + value
  #
  # ==== Examples
  #
  # valid commma case
  #
  #   {
  #     :key_1 => :value1,
  #     :key__2 => :value2,
  #     :key___3 => :value3,
  #   }.html_table
  #
  # result
  #
  #   <table>
  #     <tr>
  #       <td>key_1</td>
  #       <td>value1</td>
  #     </tr>
  #     <tr>
  #       <td>key__2</td>
  #       <td>value2</td>
  #     </tr>
  #     <tr>
  #       <td>key___3</td>
  #       <td>value3</td>
  #     </tr>
  #   </table>
  #
  def html_table
    ret = [keys, values].treduce(['<table>']) do |ret, one, other|
      ret << "  <tr>\n    <td>#{one}</td>\n    <td>#{other}</td>\n  </tr>"
      ret
    end
    ret.join("\n") + "\n</table>\n"
  end
end

Version data entries

56 entries across 56 versions & 1 rubygems

Version Path
tbpgr_utils-0.0.111 lib/open_classes/hash/html_table.rb
tbpgr_utils-0.0.110 lib/open_classes/hash/html_table.rb
tbpgr_utils-0.0.109 lib/open_classes/hash/html_table.rb
tbpgr_utils-0.0.108 lib/open_classes/hash/html_table.rb
tbpgr_utils-0.0.107 lib/open_classes/hash/html_table.rb
tbpgr_utils-0.0.106 lib/open_classes/hash/html_table.rb
tbpgr_utils-0.0.105 lib/open_classes/hash/html_table.rb
tbpgr_utils-0.0.104 lib/open_classes/hash/html_table.rb
tbpgr_utils-0.0.103 lib/open_classes/hash/html_table.rb
tbpgr_utils-0.0.102 lib/open_classes/hash/html_table.rb
tbpgr_utils-0.0.101 lib/open_classes/hash/html_table.rb
tbpgr_utils-0.0.100 lib/open_classes/hash/html_table.rb
tbpgr_utils-0.0.99 lib/open_classes/hash/html_table.rb
tbpgr_utils-0.0.98 lib/open_classes/hash/html_table.rb
tbpgr_utils-0.0.97 lib/open_classes/hash/html_table.rb
tbpgr_utils-0.0.96 lib/open_classes/hash/html_table.rb