Sha256: 333226fc378377f9b1a426cb491bccae59807b2fe92fbc151ee4e31890d1eb4b

Contents?: true

Size: 336 Bytes

Versions: 37

Compression:

Stored size: 336 Bytes

Contents

require 'sugar-high/arguments'

class Hash
  def hash_revert
    r = Hash.new {|h,k| h[k] = []}
    each {|k,v| r[v] << k}
    r
  end 
  
  def try_keys *keys
    option = last_option keys
    keys.flatten.each do |key| 
      return self[key] if self[key]
    end    
    return option[:default] if option[:default]
    nil
  end
end

Version data entries

37 entries across 37 versions & 1 rubygems

Version Path
sugar-high-0.4.4.2 lib/sugar-high/hash.rb
sugar-high-0.4.4.1 lib/sugar-high/hash.rb
sugar-high-0.4.4 lib/sugar-high/hash.rb
sugar-high-0.4.3 lib/sugar-high/hash.rb
sugar-high-0.4.0 lib/sugar-high/hash.rb
sugar-high-0.3.7 lib/sugar-high/hash.rb
sugar-high-0.3.6 lib/sugar-high/hash.rb
sugar-high-0.3.5 lib/sugar-high/hash.rb
sugar-high-0.3.4 lib/sugar-high/hash.rb
sugar-high-0.3.3 lib/sugar-high/hash.rb
sugar-high-0.3.2 lib/sugar-high/hash.rb
sugar-high-0.3.1 lib/sugar-high/hash.rb
sugar-high-0.3.0 lib/sugar-high/hash.rb
sugar-high-0.2.12 lib/sugar-high/hash.rb
sugar-high-0.2.11 lib/sugar-high/hash.rb
sugar-high-0.2.10 lib/sugar-high/hash.rb
sugar-high-0.2.9 lib/sugar-high/hash.rb