Class: Hash

Inherits:
Object
  • Object
show all
Defined in:
lib/quartz_torrent/util.rb

Instance Method Summary collapse

Instance Method Details

#pushToList(key, value) ⇒ Object

Treat the array as a hash of lists. This method will append ‘value’ to the list at key ‘key’ in the hash. If there is no list for ‘key’, one is created.



4
5
6
7
8
9
10
11
# File 'lib/quartz_torrent/util.rb', line 4

def pushToList(key, value)
  list = self[key]
  if ! list
    list = [] 
    self[key] = list
  end
  list.push value
end