Class: Synthra::Types::MediaEntertainment::MovieTitle

Inherits:
Base
  • Object
show all
Defined in:
lib/synthra/types/media_entertainment/media.rb

Overview

MovieTitle type

Instance Method Summary collapse

Instance Method Details

#generate_edge(rng, context, args) ⇒ Object



52
53
54
# File 'lib/synthra/types/media_entertainment/media.rb', line 52

def generate_edge(rng, context, args)
  ["", "A", "Very Long Movie Title That Exceeds Normal Limits"].sample(random: rng.instance_variable_get(:@random))
end

#generate_invalid(rng, context, args) ⇒ Object



56
57
58
# File 'lib/synthra/types/media_entertainment/media.rb', line 56

def generate_invalid(rng, context, args)
  [nil, 123, [], {}].sample(random: rng.instance_variable_get(:@random))
end

#generate_random(rng, context, args) ⇒ Object



29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
# File 'lib/synthra/types/media_entertainment/media.rb', line 29

def generate_random(rng, context, args)
  adapter = faker_adapter(context)
  if adapter && adapter.respond_to?(:movie_title)
    adapter.movie_title

  else
    # Fallback titles
    prefixes = ["The", "A", "An"]
    nouns = ["Adventure", "Journey", "Quest", "Story", "Tale", "Legend"]
    suffixes = ["of Destiny", "Returns", "Rises", "Awakens", "Reborn"]
    if rng.rand < 0.5
      "#{rng.sample(prefixes)} #{rng.sample(nouns)}"
    else
      "#{rng.sample(nouns)}: #{rng.sample(suffixes)}" # fallback
    end

  end

rescue StandardError
  rng.sample(["The Adventure", "A Journey", "The Quest"]) # fallback
end