Sha256: 5a2c98ff1b0947c83d0e1ad2ad28f8f3b663f6de3f6ebe28462ce525ed0c8b9c
Contents?: true
Size: 725 Bytes
Versions: 4
Compression:
Stored size: 725 Bytes
Contents
module Afipws module CoreExt module Hash def fetch_path path path.split('/').drop(1).inject(self) do |hash, key| if scan = key.scan(/\[[\d+]\]/).first key.sub! scan, '' idx = scan.scan(/\d+/).first.to_i hash.respond_to?(:has_key?) && hash.has_key?(key) ? hash[key][idx] : break else hash.respond_to?(:has_key?) && hash.has_key?(key) ? hash[key] : break end end end def select_keys *keys select { |k, _| keys.include? k } end def has_entries? entries entries.each_pair.all? { |k, v| self[k] == v } end end end end class Hash include Afipws::CoreExt::Hash end
Version data entries
4 entries across 4 versions & 1 rubygems
Version | Path |
---|---|
afipws-0.2.0 | lib/afipws/core_ext/hash.rb |
afipws-0.1.8 | lib/afipws/core_ext/hash.rb |
afipws-0.1.7 | lib/afipws/core_ext/hash.rb |
afipws-0.1.6 | lib/afipws/core_ext/hash.rb |