Module: VV::RandomMethods::ClassMethods
- Defined in:
- lib/vv/random_methods.rb
Instance Method Summary collapse
- #character(*args, capitals: false) ⇒ Object
- #default_charset ⇒ Object
- #identifier(length = nil, charset_radix: nil) ⇒ Object
- #vv_included? ⇒ Boolean
Instance Method Details
#character(*args, capitals: false) ⇒ Object
42 43 44 45 |
# File 'lib/vv/random_methods.rb', line 42 def character *args, capitals: false String.letters_and_numbers(capitals: capitals) .sample(*args, random: SecureRandom) end |
#default_charset ⇒ Object
23 24 25 |
# File 'lib/vv/random_methods.rb', line 23 def default_charset 36 end |
#identifier(length = nil, charset_radix: nil) ⇒ Object
27 28 29 30 31 32 33 34 35 36 37 38 39 40 |
# File 'lib/vv/random_methods.rb', line 27 def identifier length=nil, charset_radix: nil length ||= self.random_identifier_default_length charset_radix ||= self.default_charset largest_digit = (charset_radix - 1).to_s charset_radix start = ( largest_digit * ( length - 1 ) ).to_i charset_radix start += 1 finish = ( largest_digit * ( length ) ).to_i charset_radix range = start..finish SecureRandom.random_number(range).to_s charset_radix end |
#vv_included? ⇒ Boolean
19 20 21 |
# File 'lib/vv/random_methods.rb', line 19 def vv_included? true end |