Class: Hash
- Inherits:
-
Object
- Object
- Hash
- Defined in:
- lib/purolator_ruby/create_shipment_request.rb
Instance Method Summary collapse
-
#except(*less_keys) ⇒ Object
Returns a new hash less the given keys.
-
#except!(*rejected) ⇒ Object
Replaces hash with new hash less the given keys.
Instance Method Details
#except(*less_keys) ⇒ Object
Returns a new hash less the given keys.
4 5 6 7 8 |
# File 'lib/purolator_ruby/create_shipment_request.rb', line 4 def except(*less_keys) hash = dup less_keys.each{ |k| hash.delete(k) } hash end |
#except!(*rejected) ⇒ Object
Replaces hash with new hash less the given keys. This returns the hash of keys removed.
h = {:a=>1, :b=>2, :c=>3}
h.except!(:a) #=> {:a=>1}
h #=> {:b=>2,:c=>3}
Returns a Hash of the removed pairs.
18 19 20 21 22 |
# File 'lib/purolator_ruby/create_shipment_request.rb', line 18 def except!(*rejected) removed = {} rejected.each{ |k| removed[k] = delete(k) } removed end |