Module: CharacterTitles::Place

Defined in:
lib/character_titles/place.rb

Constant Summary collapse

ADJECTIVES =
%w(northern southern western eastern cold wintery snowy rugged dark crimson red bloody haunted)
MODIFIERS =
%w(world land realm)
PLACES =
%w(winter plains south east north west caves caverns towers)
PLACES_NEEDING_MODIFIER =
%w(under over hinter grass water wet)

Class Method Summary collapse

Class Method Details

.generateObject



30
31
32
33
34
# File 'lib/character_titles/place.rb', line 30

def generate
  place = should_modify? ? place_with_modifier : place_name
  place = "#{ADJECTIVES.sample} #{place}" if should_add_adjective?
  "#{'the' if should_be_proper?} #{place}".strip
end

.place_nameObject



26
27
28
# File 'lib/character_titles/place.rb', line 26

def place_name
  PLACES.sample
end

.place_with_modifierObject



22
23
24
# File 'lib/character_titles/place.rb', line 22

def place_with_modifier
  PLACES_NEEDING_MODIFIER.sample + MODIFIERS.sample
end

.should_add_adjective?Boolean

Returns:

  • (Boolean)


18
19
20
# File 'lib/character_titles/place.rb', line 18

def should_add_adjective?
  rand(3) == 1
end

.should_be_proper?Boolean

Returns:

  • (Boolean)


14
15
16
# File 'lib/character_titles/place.rb', line 14

def should_be_proper?
  rand(4) != 1
end

.should_modify?Boolean

Returns:

  • (Boolean)


10
11
12
# File 'lib/character_titles/place.rb', line 10

def should_modify?
  rand(3) == 1
end