Sha256: f7c716fdd62efe59bbbba60402817b9ab69819d7a8364de798596f2560cdf11d
Contents?: true
Size: 949 Bytes
Versions: 9
Compression:
Stored size: 949 Bytes
Contents
class Hash ## # Delete key-value pairs, returning the values found # using the +keys+ passed. Aliased as extract! # # === Examples # # options = { :width => 25, :height => 100 } # width, height = options.delete_at :width, :height # # width # => 25 # height # => 100 # options # => {} # def delete_at *keys keys.map { |key| delete key } end alias :extract! :delete_at ## # Return an array of switches and their arguments. # # === Examples # # { :use_foobar => true }.switchify # => ['--use-foobar'] # { :use_foobar => false }.switchify # => [] # { :interval => 15, :icon => :jpeg } # => ['--interval', '15', '--icon', 'jpeg'] # def switchify inject [] do |args, (key, value)| next args unless value args << key.to_s.switchify args << (String === value ? value.inspect : value.to_s) unless value === true args end end end
Version data entries
9 entries across 9 versions & 2 rubygems