Module: Range::RangeExtensions
- Included in:
- Range
- Defined in:
- lib/ruckus/extensions/range.rb
Instance Method Summary collapse
-
#choice ⇒ Object
(also: #choose)
Take a random number out of a range.
-
#each_backwards ⇒ Object
again, surprised this isn’t in the library.
Instance Method Details
#choice ⇒ Object 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_backwards ⇒ Object
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 |