Class: Dubs::Generator

Inherits:
Object
  • Object
show all
Defined in:
lib/dubs/generator.rb

Constant Summary collapse

DEFAULTS =
{
  theme: nil,
  category: nil,
  pattern: :default,
  token: :numeric,
  token_length: 4,
  token_case: :lower,
  separator: "-",
  adjective_group: :general,
  seed: nil
}.freeze

Instance Method Summary collapse

Constructor Details

#initialize(**options) ⇒ Generator

Returns a new instance of Generator.



17
18
19
# File 'lib/dubs/generator.rb', line 17

def initialize(**options)
  @options = DEFAULTS.merge(options)
end

Instance Method Details

#generateObject



21
22
23
24
25
26
27
28
29
# File 'lib/dubs/generator.rb', line 21

def generate
  theme = resolve_theme
  adjective = pick_adjective
  noun = pick_noun(theme)
  token_value = generate_token

  template = Pattern.resolve(@options[:pattern])
  Pattern.interpolate(template, adjective: adjective, noun: noun, token: token_value, separator: @options[:separator])
end