Module: RujitsuRange
- Defined in:
- lib/rujitsu/range.rb
Instance Method Summary collapse
-
#random_characters ⇒ Object
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.
-
#random_hex_characters ⇒ Object
create a string of random hex characters whose length is one of the values in your range (3..4).random_hex_characters # => returns a string of 3 or 4 random hex characters.
-
#random_letters ⇒ Object
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.
-
#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.
-
#to_random_i ⇒ Object
pull a random element out of this range.
Instance Method Details
#random_characters ⇒ Object
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
23 24 25 |
# File 'lib/rujitsu/range.rb', line 23 def random_characters self.to_random_i.random_characters end |
#random_hex_characters ⇒ Object
create a string of random hex characters whose length is one of the values in your range (3..4).random_hex_characters # => returns a string of 3 or 4 random hex characters
29 30 31 |
# File 'lib/rujitsu/range.rb', line 29 def random_hex_characters self.to_random_i.random_hex_characters end |
#random_letters ⇒ Object
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
11 12 13 |
# File 'lib/rujitsu/range.rb', line 11 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
17 18 19 |
# File 'lib/rujitsu/range.rb', line 17 def random_numbers opts = {} self.to_random_i.random_numbers opts end |
#to_random_i ⇒ Object
pull a random element out of this range
5 6 7 |
# File 'lib/rujitsu/range.rb', line 5 def to_random_i self.to_a.sort_by { rand }.first end |