Class Hash

  1. lib/cloudkit.rb
Parent: Object

Methods

public instance

  1. excluding
  2. filter_merge!
  3. rekey!

Public instance methods

excluding (*keys)

Return a new Hash, excluding the specified list of keys.

[show source]
    # File lib/cloudkit.rb, line 78
78:   def excluding(*keys)
79:     trimmed = self.dup
80:     keys.each{|k| trimmed.delete(k)}
81:     trimmed
82:   end
filter_merge! (other={})

For each key in ‘other’ that has a non-nil value, merge it into the current Hash.

[show source]
    # File lib/cloudkit.rb, line 64
64:   def filter_merge!(other={})
65:     other.each_pair{|k,v| self.merge!(k => v) unless v.nil?}
66:     self
67:   end
rekey! (oldkey, newkey)

Change the key ‘oldkey’ to ‘newkey’

[show source]
    # File lib/cloudkit.rb, line 70
70:   def rekey!(oldkey, newkey)
71:     if self.has_key? oldkey
72:       self[newkey] = self.delete(oldkey)
73:     end
74:     nil
75:   end