Module: RandomNameGenerator
- Defined in:
- lib/random_name_generator.rb,
lib/random_name_generator/version.rb,
lib/random_name_generator/syllable.rb
Overview
RandomNameGenerator:
Examples
rng = RandomNameGenerator::Generator.new(RandomNameGenerator::GOBLIN)
puts rng.compose(3)
By default RandomNameGenerator uses the Fantasy syllable file and creates a name with between 2 and 5 syllables.
rng = RandomNameGenerator::Generator.new
puts rng.compose
:reek:TooManyConstants :reek:TooManyInstanceVariables :reek:TooManyStatements
Defined Under Namespace
Constant Summary collapse
- ELVEN =
File.new("#{dirname}/languages/elven.txt")
- FANTASY =
File.new("#{dirname}/languages/fantasy.txt")
- GOBLIN =
File.new("#{dirname}/languages/goblin.txt")
- ROMAN =
File.new("#{dirname}/languages/roman.txt")
- ELVEN_RU =
File.new("#{dirname}/languages/elven-ru.txt")
- FANTASY_RU =
File.new("#{dirname}/languages/fantasy-ru.txt")
- GOBLIN_RU =
File.new("#{dirname}/languages/goblin-ru.txt")
- ROMAN_RU =
File.new("#{dirname}/languages/roman-ru.txt")
- BELTER =
File.new("#{dirname}/languages/belter.txt")
- KLINGON =
File.new("#{dirname}/languages/klingon.txt")
- WELSH =
File.new("#{dirname}/languages/welsh.txt")
- CURSE =
Experimental
File.new("#{dirname}/languages/experimental/curse.txt")
- DEMONIC =
File.new("#{dirname}/languages/experimental/demonic.txt")
- GERMAN_CURSE =
File.new("#{dirname}/languages/experimental/german-curse.txt")
- VERSION =
"4.0.4"
Class Method Summary collapse
-
.flip_mode ⇒ Object
Static factory method that instantiates a RandomNameGenerator in a random language.
-
.flip_mode_cyrillic ⇒ Object
Static factory method that instantiates a RandomNameGenerator in a random Cyrillic based language.
-
.new(language = RandomNameGenerator::FANTASY, random: Random.new) ⇒ Object
Static factory method for the Generator class.
- .pick_number_of_syllables(random: Random.new) ⇒ Object
Class Method Details
.flip_mode ⇒ Object
Static factory method that instantiates a RandomNameGenerator in a random language.
44 45 46 47 48 49 50 |
# File 'lib/random_name_generator.rb', line 44 def self.flip_mode langs = [RandomNameGenerator::FANTASY, RandomNameGenerator::ELVEN, RandomNameGenerator::GOBLIN, RandomNameGenerator::ROMAN] Generator.new(langs.sample) end |
.flip_mode_cyrillic ⇒ Object
Static factory method that instantiates a RandomNameGenerator in a random Cyrillic based language.
54 55 56 57 58 59 60 |
# File 'lib/random_name_generator.rb', line 54 def self.flip_mode_cyrillic langs = [RandomNameGenerator::FANTASY_RU, RandomNameGenerator::ELVEN_RU, RandomNameGenerator::GOBLIN_RU, RandomNameGenerator::ROMAN_RU] Generator.new(langs.sample) end |
.new(language = RandomNameGenerator::FANTASY, random: Random.new) ⇒ Object
Static factory method for the Generator class.
67 68 69 |
# File 'lib/random_name_generator.rb', line 67 def self.new(language = RandomNameGenerator::FANTASY, random: Random.new) Generator.new(language, random: random) end |
.pick_number_of_syllables(random: Random.new) ⇒ Object
62 63 64 |
# File 'lib/random_name_generator.rb', line 62 def self.pick_number_of_syllables(random: Random.new) [2, 2, 2, 2, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 4, 4, 4, 5].sample(random: random) end |