class Hash

Hash

Hash

Hash

Public Instance Methods

>>(dummy = nil) click to toggle source

return HashContext for each execute

Example

h = {key1: "value1", key2: "value2"}
h.>>.upcase # => {key1: "VALUE1", key2: "VALUE2"}
h.>>.+('_hoge') # => {key1: "value1_hoge", key2: "value2_hoge"}
# File lib/open_classes/hash/gte_gte.rb, line 42
def >>(dummy = nil)
  HashContext.new(self)
end
html_table() click to toggle source

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>
# File lib/open_classes/hash/html_table.rb, line 34
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
table() click to toggle source

get pipe format table string from key + value

Examples

valid commma case

{
  :key_1 => :value1___________________,
  :key__2 => :value2,
  :key___3 => :value3,
}.table

result

|key_1  |value1___________________|
|key__2 |value2                   |
|key___3|value3                   |
# File lib/open_classes/hash/table.rb, line 23
def table
  ret = [keys, values].treduce([]) do |ret, one, other|
    ret << "|#{one}|#{other}|"
    ret
  end
  ret = ret.join("\n") + "\n"
  ret.justify_table
end