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.151 lib/open_classes/hash/html_table.rb
tbpgr_utils-0.0.150 lib/open_classes/hash/html_table.rb
tbpgr_utils-0.0.149 lib/open_classes/hash/html_table.rb
tbpgr_utils-0.0.148 lib/open_classes/hash/html_table.rb
tbpgr_utils-0.0.147 lib/open_classes/hash/html_table.rb
tbpgr_utils-0.0.146 lib/open_classes/hash/html_table.rb
tbpgr_utils-0.0.145 lib/open_classes/hash/html_table.rb
tbpgr_utils-0.0.144 lib/open_classes/hash/html_table.rb
tbpgr_utils-0.0.143 lib/open_classes/hash/html_table.rb
tbpgr_utils-0.0.142 lib/open_classes/hash/html_table.rb
tbpgr_utils-0.0.141 lib/open_classes/hash/html_table.rb
tbpgr_utils-0.0.140 lib/open_classes/hash/html_table.rb
tbpgr_utils-0.0.139 lib/open_classes/hash/html_table.rb
tbpgr_utils-0.0.138 lib/open_classes/hash/html_table.rb
tbpgr_utils-0.0.137 lib/open_classes/hash/html_table.rb
tbpgr_utils-0.0.136 lib/open_classes/hash/html_table.rb
tbpgr_utils-0.0.135 lib/open_classes/hash/html_table.rb
tbpgr_utils-0.0.134 lib/open_classes/hash/html_table.rb
tbpgr_utils-0.0.133 lib/open_classes/hash/html_table.rb
tbpgr_utils-0.0.132 lib/open_classes/hash/html_table.rb