Module: Enumerable
- Defined in:
- lib/mongo_oplog_backup/ext/enumerable.rb
Overview
Define Enumerable#sorted?
Instance Method Summary collapse
-
#increasing? ⇒ Boolean
Strictly increasing, in other words sorted and unique.
-
#sorted? ⇒ Boolean
Sorted in ascending order.
Instance Method Details
permalink #increasing? ⇒ Boolean
Strictly increasing, in other words sorted and unique
12 13 14 15 16 |
# File 'lib/mongo_oplog_backup/ext/enumerable.rb', line 12 def increasing? each_cons(2).all? do |a, b| (a <=> b) < 0 end end |
permalink #sorted? ⇒ Boolean
Sorted in ascending order
5 6 7 8 9 |
# File 'lib/mongo_oplog_backup/ext/enumerable.rb', line 5 def sorted? each_cons(2).all? do |a, b| (a <=> b) <= 0 end end |