Module: DOUsername

Extended by:
DOUsername
Included in:
DOUsername
Defined in:
lib/do_username.rb

Constant Summary collapse

SEA_CREATURES =
%w[
  walrus seal fish shark clam coral whale crab lobster starfish eel dolphin
  squid jellyfish ray shrimp mantaRay angler snorkler scubaDiver urchin
  anemone morel axolotl
].freeze
SEA_OBJECTS =
%w[boat ship submarine yacht dinghy raft kelp seaweed anchor].freeze
ADJECTIVE_DESCRIPTORS =
%w[cute adorable lovable happy sandy bubbly friendly floating drifting].freeze
SIZE_DESCRIPTORS =
%w[large big small giant massive tiny little].freeze
CREATURE_DESCRIPTORS =
%w[swimming sleeping eating hiding].freeze
SEA_LIST =
(SEA_OBJECTS + SEA_CREATURES).freeze
DESCRIPTORS =
(ADJECTIVE_DESCRIPTORS + SIZE_DESCRIPTORS).freeze
COLORS =
%w[
  blue blueGreen darkCyan electricBlue greenBlue lightCyan lightSeaGreen seaGreen
  turquoise aqua aquamarine teal cyan gray darkBlue cerulean azure lapis navy
].freeze

Instance Method Summary collapse

Instance Method Details

#generate(max_size = 30) ⇒ Object

Raises:

  • (ArgumentError)


23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
# File 'lib/do_username.rb', line 23

def generate(max_size = 30)
  raise ArgumentError, 'The max_size argument must be an integer number greater than zero.' if max_size.to_i <= 0

  # Choose a noun first
  noun = random_noun

  # Choose a descriptor
  descriptor = random_descriptor(noun)

  # Choose a color
  color = random_color

  # Convert to title case and remove whitespace
  noun = format(noun)
  descriptor = format(descriptor)
  color = format(color)

  combine_username(max_size, descriptor, color, noun)
end