Method: Wpxf::Utility::Text.rand_numeric
- Defined in:
- lib/wpxf/utility/text.rb
.rand_numeric(length, allow_leading_zero = false) ⇒ String
Generate a random numeric string.
13 14 15 16 17 |
# File 'lib/wpxf/utility/text.rb', line 13 def self.rand_numeric(length, allow_leading_zero = false) value = Array.new(length) { [*'0'..'9'].sample }.join value[0] = [*'1'..'9'].sample unless allow_leading_zero value end |