Class: Range

Inherits:
Object show all
Defined in:
lib/rujitsu/range.rb

Instance Method Summary collapse

Instance Method Details

#random_charactersObject

create a string of random characters whose length is one of the values in your range (3..4).random_characters # => returns a string or 3 or 4 random characters



21
22
23
# File 'lib/rujitsu/range.rb', line 21

def random_characters
	self.to_random_i.random_characters
end

#random_lettersObject

create a string of random letters whose length is one of the values in your range (3..4).random_letters # => returns a string or 3 or 4 random letters



9
10
11
# File 'lib/rujitsu/range.rb', line 9

def random_letters
	self.to_random_i.random_letters
end

#random_numbers(opts = {}) ⇒ Object

create a string of random numbers whose length is one of the values in your range (3..4).random_numbers # => returns a string or 3 or 4 random numbers



15
16
17
# File 'lib/rujitsu/range.rb', line 15

def random_numbers opts = {}
	self.to_random_i.random_numbers opts
end

#to_random_iObject

pull a random element out of this range



3
4
5
# File 'lib/rujitsu/range.rb', line 3

def to_random_i
	self.to_a.sort_by { rand }.first
end