Class: Range
- Inherits:
-
Object
- Object
- Range
- 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_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
21 22 23 |
# File 'lib/rujitsu/range.rb', line 21 def random_characters self.to_random_i.random_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
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_i ⇒ Object
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 |