Module Spruz::Subhash
In: lib/spruz/subhash.rb

Methods

subhash  

Public Instance methods

Create a subhash from this hash, that only contains key-value pairs matching patterns and return it. patterns can be for example /^foo/ to put ‘foobar’ and ‘foobaz’ or ‘foo’/:foo to put ‘foo’ into the subhash.

If a block is given this method yields to it after the first pattern matched with a 3-tuple of +(key, value, match_data)+ using the return value of the block as the value of the result hash. match_data is a MatchData instance if the matching pattern was a regular rexpression otherwise it is nil.

[Validate]