Class: Hash
Instance Method Summary collapse
- #decrement(index, quantity = 1) ⇒ Object
- #increment(index, quantity = 1) ⇒ Object
- #sort(&block) ⇒ Object
Instance Method Details
#decrement(index, quantity = 1) ⇒ Object
64 65 66 |
# File 'lib/libaaron.rb', line 64 def decrement(index, quantity = 1) increment(index, -quantity) end |
#increment(index, quantity = 1) ⇒ Object
56 57 58 59 60 61 62 63 |
# File 'lib/libaaron.rb', line 56 def increment(index, quantity = 1) if self[index] self[index] += quantity else self[index] = quantity end return self[index] end |
#sort(&block) ⇒ Object
67 68 69 70 |
# File 'lib/libaaron.rb', line 67 def sort(&block) block = Proc.new {|a,b| a[1] <=> b[1]} if block.nil? super(&block) end |