Class: Hash

Inherits:
Object
  • Object
show all
Defined in:
lib/base/hash.rb

Instance Method Summary collapse

Instance Method Details

#execute(value = nil) ⇒ Object


6
7
8
9
10
11
12
13
14
15
# File 'lib/base/hash.rb', line 6

def execute(value = nil)
  each do |k, v|
    v.update if v.respond_to?(:update)
    if v.is_a?(Array) && v.length.zero?
      delete k
    elsif v.respond_to?(:execute)
      v.execute(value)
    end
  end
end

#to_htmlObject


17
18
19
20
21
22
23
24
25
# File 'lib/base/hash.rb', line 17

def to_html
  [
    "<div>",
    map do |k, v|
      ["<br/><div><strong>#{k}</strong>", v.respond_to?(:to_html) ? v.to_html : "<span>#{v}</span></div><br/>"]
    end,
    "</div>",
  ].join
end