Module: Increments

Defined in:
lib/increments.rb

Class Method Summary collapse

Class Method Details

.decrement(opts = {}, &block) ⇒ Object



10
11
12
13
14
15
16
17
18
19
20
# File 'lib/increments.rb', line 10

def self.decrement(opts={},&block)
  options = defaults.merge(opts)
  validate(options,&block)
  min, max = [options[:min], options[:max] - options[:increment]+1].max, options[:max]
  loop do
    yield(min,max)
    break if min == options[:min]
    min = [min - options[:increment], options[:min]].max
    max = [max - options[:increment], options[:min]].max
  end
end

.increment(opts = {}, &block) ⇒ Object



2
3
4
5
6
7
8
# File 'lib/increments.rb', line 2

def self.increment(opts={},&block)
  options = defaults.merge(opts)
       validate(options,&block)
       step_enum(options).each do |min|
    yield(min,range_max(min,options))
  end
end