Class: Synthra::Types::TextContent::Words
- Defined in:
- lib/synthra/types/text_content/text_generation.rb
Overview
Words type
Instance Method Summary collapse
- #generate_edge(rng, context, args) ⇒ Object
- #generate_invalid(rng, context, args) ⇒ Object
- #generate_random(rng, context, args) ⇒ Object
Instance Method Details
#generate_edge(rng, context, args) ⇒ Object
66 67 68 |
# File 'lib/synthra/types/text_content/text_generation.rb', line 66 def generate_edge(rng, context, args) ["", "a", "word"].sample(random: rng.instance_variable_get(:@random)) end |
#generate_invalid(rng, context, args) ⇒ Object
70 71 72 |
# File 'lib/synthra/types/text_content/text_generation.rb', line 70 def generate_invalid(rng, context, args) [nil, 123, [], {}].sample(random: rng.instance_variable_get(:@random)) end |
#generate_random(rng, context, args) ⇒ Object
54 55 56 57 58 59 60 61 62 63 |
# File 'lib/synthra/types/text_content/text_generation.rb', line 54 def generate_random(rng, context, args) min = args[:min] || 3 max = args[:max] || 10 count = rng.int(min, max) # English-readable words — Faker::Hipster reads as English, unlike Latin Lorem. Faker::Hipster.words(number: count).join(" ") rescue StandardError rng.sample(["word one two", "test data here", "sample words"]) end |