Module: Range::RangeExtensions

Included in:
Range
Defined in:
lib/ruckus/extensions/range.rb

Instance Method Summary collapse

Instance Method Details

#choiceObject Also known as: choose

Take a random number out of a range



10
11
12
# File 'lib/ruckus/extensions/range.rb', line 10

def choice
    rand(self.last - self.first) + self.first
end

#each_backwardsObject

again, surprised this isn’t in the library



4
5
6
# File 'lib/ruckus/extensions/range.rb', line 4

def each_backwards
    max.to_i.downto(min) {|i| yield i}
end