Module: GMO::PG::Util::RandomString
- Defined in:
- lib/gmo-pg/util.rb
Class Method Summary collapse
Class Method Details
.generate(prefix: '', suffix: '', chars: [], length: 0) ⇒ Object
5 6 7 8 9 10 11 12 13 14 |
# File 'lib/gmo-pg/util.rb', line 5 def self.generate(prefix: '', suffix: '', chars: [], length: 0) str = '' prefix = prefix.to_s suffix = suffix.to_s str << prefix (length - prefix.length - suffix.length).times { str << chars.sample } str << suffix end |