module Quickstrings
Constants
- EMAILS
- FULLNAMES
- IMAGES
- NAMES
- URLS
Feel free to add items to the end of the arrays Specific functions are written to return the first thing in the array, so DO NOT add any new items in the first position of the arrays.
Doing so will break tests and expected behavior.
- UTF8SAMPLE
UTF8 sampling focus on umlauted characters from 00C0 to 00FF see www.utf8-chartable.de/ Chars 00D7 and 00F7 would for some reason stop the next ones from generating, so they’re excluded
- VERSION
Public Instance Methods
email()
click to toggle source
# File lib/quickstrings.rb, line 32 def email EMAILS.first end
flname()
click to toggle source
# File lib/quickstrings.rb, line 48 def flname FULLNAMES.first end
fname()
click to toggle source
# File lib/quickstrings.rb, line 40 def fname NAMES.first end
image(size = nil)
click to toggle source
# File lib/quickstrings.rb, line 60 def image(size = nil) IMAGES.first + (size.nil? ? "":"?s=#{size}") end
remail()
click to toggle source
# File lib/quickstrings.rb, line 36 def remail EMAILS.sample end
rflname()
click to toggle source
# File lib/quickstrings.rb, line 52 def rflname FULLNAMES.sample end
rfname()
click to toggle source
# File lib/quickstrings.rb, line 44 def rfname NAMES.sample end
rimage(size = nil)
click to toggle source
# File lib/quickstrings.rb, line 64 def rimage(size = nil) IMAGES.sample + (size.nil? ? "":"?s=#{size}") end
rstring(length = 1, delim = nil)
click to toggle source
# File lib/quickstrings.rb, line 68 def rstring(length = 1, delim = nil) new_string = whitelist_string ('a'..'z'), length if !delim.nil? new_string[0] = delim new_string[-1] = delim end new_string end
rurl()
click to toggle source
# File lib/quickstrings.rb, line 28 def rurl URLS.sample end
rutf8string(length = 1)
click to toggle source
# File lib/quickstrings.rb, line 56 def rutf8string(length = 1) whitelist_string UTF8SAMPLE, length end
url()
click to toggle source
# File lib/quickstrings.rb, line 24 def url URLS.first end
whitelist_string(whitelist, length)
click to toggle source
# File lib/quickstrings.rb, line 79 def whitelist_string(whitelist, length) case(whitelist) when Range whitelist = whitelist.to_a when String whitelist = whitelist.split("") when Fixnum whitelist = whitelist.to_s.split("") end output = "" length.times do output += whitelist.sample end output end