Parent

Randgen

Constants

WORDS_PER_SENTENCE
SENTENCES_PER_PARAGRAPH

Public Class Methods

alpha_numeric(options = {}) click to toggle source
    # File lib/randexp/randgen.rb, line 29
29:   def self.alpha_numeric(options = {})
30:     [char, digit].pick
31:   end
bool(options = {}) click to toggle source
   # File lib/randexp/randgen.rb, line 5
5:   def self.bool(options = {})
6:     ['true', 'false'].pick
7:   end
char(options = {}) click to toggle source
    # File lib/randexp/randgen.rb, line 17
17:   def self.char(options = {})
18:     [lchar, uchar].pick
19:   end
digit(options = {}) click to toggle source
    # File lib/randexp/randgen.rb, line 25
25:   def self.digit(options = {})
26:     ('0'..'9').to_a.pick
27:   end
email(options = {}) click to toggle source
    # File lib/randexp/randgen.rb, line 58
58:   def self.email(options = {})
59:     domain = options.fetch(:domain, "#{word(options)}.example.org")
60:     "#{word(options)}@#{domain}"
61:   end
first_name(options = {}) click to toggle source
    # File lib/randexp/randgen.rb, line 42
42:   def self.first_name(options = {})
43:     RealName.first_names(options).pick
44:   end
lchar(options = {}) click to toggle source
    # File lib/randexp/randgen.rb, line 9
 9:   def self.lchar(options = {})
10:     ('a'..'z').to_a.pick
11:   end
name(options = {}) click to toggle source
    # File lib/randexp/randgen.rb, line 54
54:   def self.name(options = {})
55:     "#{first_name(options)} #{surname(options)}"
56:   end
paragraph(options = {}) click to toggle source
    # File lib/randexp/randgen.rb, line 67
67:   def self.paragraph(options = {})
68:     ((options[:length] || SENTENCES_PER_PARAGRAPH.pick).of { sentence } * ".  ") + "."
69:   end
phone_number(options = {}) click to toggle source
    # File lib/randexp/randgen.rb, line 71
71:   def self.phone_number(options = {})
72:     case options[:length]
73:     when 7  then  /\d{3}-\d{4}/.gen
74:     when 10 then  /\d{3}-\d{3}-\d{4}/.gen
75:     else          /(\d{3}-)?\d{3}-\d{4}/.gen
76:     end
77:   end
sentence(options = {}) click to toggle source
    # File lib/randexp/randgen.rb, line 63
63:   def self.sentence(options = {})
64:     ((options[:length] || WORDS_PER_SENTENCE.pick).of { word } * " ").capitalize
65:   end
surname(options = {}) click to toggle source
    # File lib/randexp/randgen.rb, line 46
46:   def self.surname(options = {})
47:     RealName.surnames(options).pick
48:   end
uchar(options = {}) click to toggle source
    # File lib/randexp/randgen.rb, line 13
13:   def self.uchar(options = {})
14:     ('A'..'Z').to_a.pick
15:   end
whitespace(options = {}) click to toggle source
    # File lib/randexp/randgen.rb, line 21
21:   def self.whitespace(options = {})
22:     ["\t", "\n", "\r", "\f"].pick
23:   end
word(options = {}) click to toggle source
    # File lib/randexp/randgen.rb, line 33
33:   def self.word(options = {})
34:     begin
35:       word = Randexp::Dictionary.words(options).pick
36:       word ||= options[:length].of { alpha_numeric }.join
37:     end until word =~ /^\w+$/
38: 
39:     word
40:   end

Disabled; run with --debug to generate this.

[Validate]

Generated with the Darkfish Rdoc Generator 1.1.6.