Sha256: 041f72fc4e40290cef5468b0b48b4c64b1eff5933a375e9c9c644e60122798b8

Contents?: true

Size: 551 Bytes

Versions: 1

Compression:

Stored size: 551 Bytes

Contents

# frozen_string_literal: true

puts __FILE__ if defined?(DEBUG)

class Hash
  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

  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
end

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
dev-2.1.154 lib/base/hash.rb