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.6.0 lib/sugar-high/hash.rb
sugar-high-0.5.5 lib/sugar-high/hash.rb
sugar-high-0.5.4 lib/sugar-high/hash.rb
sugar-high-0.5.3 lib/sugar-high/hash.rb
sugar-high-0.5.1 lib/sugar-high/hash.rb
sugar-high-0.5.0 lib/sugar-high/hash.rb
sugar-high-0.4.9.5 lib/sugar-high/hash.rb
sugar-high-0.4.9.3 lib/sugar-high/hash.rb
sugar-high-0.4.9.2 lib/sugar-high/hash.rb
sugar-high-0.4.9.1 lib/sugar-high/hash.rb
sugar-high-0.4.9 lib/sugar-high/hash.rb
sugar-high-0.4.8 lib/sugar-high/hash.rb
sugar-high-0.4.7 lib/sugar-high/hash.rb
sugar-high-0.4.6.4 lib/sugar-high/hash.rb
sugar-high-0.4.6.3 lib/sugar-high/hash.rb
sugar-high-0.4.6.2 lib/sugar-high/hash.rb
sugar-high-0.4.6.1 lib/sugar-high/hash.rb
sugar-high-0.4.6 lib/sugar-high/hash.rb
sugar-high-0.4.5.2 lib/sugar-high/hash.rb
sugar-high-0.4.5 lib/sugar-high/hash.rb