Parent

Randgen

Public Class Methods

alpha_numeric(options = {}) click to toggle source
# File lib/randexp/randgen.rb, line 29
def self.alpha_numeric(options = {})
  [char, digit].pick
end
bool(options = {}) click to toggle source
# File lib/randexp/randgen.rb, line 5
def self.bool(options = {})
  ['true', 'false'].pick
end
char(options = {}) click to toggle source
# File lib/randexp/randgen.rb, line 17
def self.char(options = {})
  [lchar, uchar].pick
end
digit(options = {}) click to toggle source
# File lib/randexp/randgen.rb, line 25
def self.digit(options = {})
  ('0'..'9').to_a.pick
end
email(options = {}) click to toggle source
# File lib/randexp/randgen.rb, line 58
def self.email(options = {})
  domain = options.fetch(:domain, "#{word(options)}.example.org")
  "#{word(options)}@#{domain}"
end
first_name(options = {}) click to toggle source
# File lib/randexp/randgen.rb, line 42
def self.first_name(options = {})
  RealName.first_names(options).pick
end
last_name(options = {}) click to toggle source
Alias for: surname
lchar(options = {}) click to toggle source
# File lib/randexp/randgen.rb, line 9
def self.lchar(options = {})
  ('a'..'z').to_a.pick
end
name(options = {}) click to toggle source
# File lib/randexp/randgen.rb, line 54
def self.name(options = {})
  "#{first_name(options)} #{surname(options)}"
end
paragraph(options = {}) click to toggle source
# File lib/randexp/randgen.rb, line 67
def self.paragraph(options = {})
  ((options[:length] || SENTENCES_PER_PARAGRAPH.pick).of { sentence } * ".  ") + "."
end
phone_number(options = {}) click to toggle source
# File lib/randexp/randgen.rb, line 71
def self.phone_number(options = {})
  case options[:length]
  when 7  then  /\d{3}-\d{4}/.gen
  when 10 then  /\d{3}-\d{3}-\d{4}/.gen
  else          /(\d{3}-)?\d{3}-\d{4}/.gen
  end
end
sentence(options = {}) click to toggle source
# File lib/randexp/randgen.rb, line 63
def self.sentence(options = {})
  ((options[:length] || WORDS_PER_SENTENCE.pick).of { word } * " ").capitalize
end
surname(options = {}) click to toggle source
# File lib/randexp/randgen.rb, line 46
def self.surname(options = {})
  RealName.surnames(options).pick
end
Also aliased as: last_name
uchar(options = {}) click to toggle source
# File lib/randexp/randgen.rb, line 13
def self.uchar(options = {})
  ('A'..'Z').to_a.pick
end
whitespace(options = {}) click to toggle source
# File lib/randexp/randgen.rb, line 21
def self.whitespace(options = {})
  ["\t", "\n", "\r", "\f"].pick
end
word(options = {}) click to toggle source
# File lib/randexp/randgen.rb, line 33
def self.word(options = {})
  begin
    word = Randexp::Dictionary.words(options).pick
    word ||= options[:length].of { alpha_numeric }.join
  end until word =~ /^\w+$/

  word
end

[Validate]

Generated with the Darkfish Rdoc Generator 2.