Skip to content

Instantly share code, notes, and snippets.

@benaubin
Forked from lpar/pwgen.rb
Last active February 15, 2016 22:25
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save benaubin/0fa450ee5d52507543d8 to your computer and use it in GitHub Desktop.
Save benaubin/0fa450ee5d52507543d8 to your computer and use it in GitHub Desktop.
Simple generation of readable random made-up words using Ruby
#!/usr/bin/env ruby
# encoding: UTF-8
# Simple word gen in Ruby.
#
# Example:
#
# gen
# gen 10
# gen 7, "prefix-"
SYLLABLES = %w(ba be bi bo bu by da de di do du dy fe fi fo fu fy ga ge gi
go gu gy ha he hi ho hu hy ja je ji jo ju jy ka ke ko ku ky la le li lo
lu ly ma me mi mo mu my na ne ni no nu ny pa pe pi po pu py ra re ri ro
ru ry sa se si so su sy ta te ti to tu ty va ve vi vo vu vy bra bre bri
bro bru bry dra dre dri dro dru dry fra fre fri fro fru fry gra gre gri
gro gru gry pra pre pri pro pru pry sta ste sti sto stu sty tra tre er
ed in ex al en an ad or at ca ap el ci an et it ob of af au cy im op co
up ing con ter com per ble der cal man est for mer col ful get low son
tle day pen pre ten tor ver ber can ple fer gen den mag sub sur men min
out tal but cit cle cov dif ern eve hap ket nal sup ted tem tin tro tro)
SYMBOLS = %w(- _ .)
def gen(length=7, result="", syllable = (length % 5 == 0 ? SYMBOLS : SYLLABLES).sample)
length > 0 ? gen(length - syllable.length, result + syllable) : result[0..length-1]
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment