Class: Synthra::Types::TextContent::Sentences
- Defined in:
- lib/synthra/types/text_content/text_generation.rb
Overview
Sentences 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
43 44 45 |
# File 'lib/synthra/types/text_content/text_generation.rb', line 43 def generate_edge(rng, context, args) ["", "A single sentence."].sample(random: rng.instance_variable_get(:@random)) end |
#generate_invalid(rng, context, args) ⇒ Object
47 48 49 |
# File 'lib/synthra/types/text_content/text_generation.rb', line 47 def generate_invalid(rng, context, args) [nil, 123, [], {}].sample(random: rng.instance_variable_get(:@random)) end |
#generate_random(rng, context, args) ⇒ Object
31 32 33 34 35 36 37 38 39 40 |
# File 'lib/synthra/types/text_content/text_generation.rb', line 31 def generate_random(rng, context, args) min = args[:min] || 1 max = args[:max] || 5 count = rng.int(min, max) # English-readable sentences — Faker::Hipster reads as English, unlike Latin Lorem. Faker::Hipster.sentences(number: count).join(" ") rescue StandardError "Sentence one. Sentence two. Sentence three." end |