Class: Dictionary

Inherits:
Object show all
Defined in:
lib/ruber/utils.rb

Instance Method Summary (collapse)

Instance Method Details

- (Object) order_by_key

Works as the method with the same name in facets but works around a bug with facets and ruby 1.9



279
280
281
282
283
# File 'lib/ruber/utils.rb', line 279

def order_by_key
  @order_by = lambda { |i| i[0] }
  order
  self
end

- (Object) order_by_value

Works as the method with the same name in facets but works around a bug with facets and ruby 1.9



268
269
270
271
272
# File 'lib/ruber/utils.rb', line 268

def order_by_value
  @order_by = lambda { |i| i[0] }
  order
  self
end

- (Dictionary) reverse_each { ... }

Calls the block passing it each key and the corresponding value starting from the last

Yields:

  • key, value

Returns:



293
294
295
296
# File 'lib/ruber/utils.rb', line 293

def reverse_each
  order.reverse_each{|k| yield k, @hash[k] }
  self
end