Parent

RealName

Public Class Methods

female_first_names(options = {}) click to toggle source
# File lib/randexp/wordlists/female_names.rb, line 12
def self.female_first_names(options = {})
  if options.has_key?(:length)
    female_first_names_by_length[options[:length]]
  else
    @@female_first_names ||= load_female_first_names
  end
end
female_first_names_by_length() click to toggle source
# File lib/randexp/wordlists/female_names.rb, line 20
def self.female_first_names_by_length
  @@female_first_names_by_length ||= female_first_names.inject({}) {|h, w| (h[w.size] ||= []) << w; h }
end
first_names(options) click to toggle source
# File lib/randexp/wordlists/real_name.rb, line 23
def self.first_names(options)
  case options[:gender].to_s
  when /^male/
    male_first_names(options)
  when /^female/
    female_first_names(options)
  else
    [male_first_names(options), female_first_names(options)].pick
  end
end
load_female_first_names() click to toggle source
# File lib/randexp/wordlists/female_names.rb, line 3
def self.load_female_first_names
  dir = File.dirname(__FILE__)
  if File.exists?("#{dir}/../../../wordlists/female_names")
    File.read("#{dir}/../../../wordlists/female_names").split
  else
    raise "words file not found"
  end
end
load_male_first_names() click to toggle source
# File lib/randexp/wordlists/male_names.rb, line 3
def self.load_male_first_names
  dir = File.dirname(__FILE__)
  if File.exists?("#{dir}/../../../wordlists/male_names")
    File.read("#{dir}/../../../wordlists/male_names").split
  else
    raise "words file not found"
  end
end
load_surnames() click to toggle source
# File lib/randexp/wordlists/real_name.rb, line 2
def self.load_surnames
  dir = File.dirname(__FILE__)
  if File.exists?("#{dir}/../../../wordlists/surnames")
    File.read("#{dir}/../../../wordlists/surnames").split
  else
    raise "words file not found"
  end
end
male_first_names(options = {}) click to toggle source
# File lib/randexp/wordlists/male_names.rb, line 12
def self.male_first_names(options = {})
  if options.has_key?(:length)
    male_first_names_by_length[options[:length]]
  else
    @@male_first_names ||= load_male_first_names
  end
end
male_first_names_by_length() click to toggle source
# File lib/randexp/wordlists/male_names.rb, line 20
def self.male_first_names_by_length
  @@male_first_names_by_length ||= male_first_names.inject({}) {|h, w| (h[w.size] ||= []) << w; h }
end
surnames(options = {}) click to toggle source
# File lib/randexp/wordlists/real_name.rb, line 11
def self.surnames(options = {})
  if options.has_key?(:length)
    surnames_by_length[options[:length]]
  else
    @@surnames ||= load_surnames
  end
end
surnames_by_length() click to toggle source
# File lib/randexp/wordlists/real_name.rb, line 19
def self.surnames_by_length
  @@surnames_by_length ||= surnames.inject({}) {|h, w| (h[w.size] ||= []) << w; h }
end

[Validate]

Generated with the Darkfish Rdoc Generator 2.