Class: Synthra::Types::TextContent::SocialHandle

Inherits:
Base
  • Object
show all
Defined in:
lib/synthra/types/text_content/text_generation.rb

Overview

Twitter/social handle (without @ prefix)

Generates username-style handles for social media.

Instance Method Summary collapse

Instance Method Details

#generate_edge(rng, context, args) ⇒ Object



491
492
493
# File 'lib/synthra/types/text_content/text_generation.rb', line 491

def generate_edge(rng, context, args)
  rng.sample(["", "a", "user_" + ("x" * 50)])
end

#generate_invalid(rng, context, args) ⇒ Object



495
496
497
# File 'lib/synthra/types/text_content/text_generation.rb', line 495

def generate_invalid(rng, context, args)
  rng.sample([nil, 123, [], "@invalid"])
end

#generate_random(rng, context, args) ⇒ Object



477
478
479
480
481
482
483
484
485
486
487
488
# File 'lib/synthra/types/text_content/text_generation.rb', line 477

def generate_random(rng, context, args)
  adapter = faker_adapter(context)
  if adapter
    adapter.fetch("internet.username")

  else
    Faker::Internet.username(specifier: 5..15)
  end

rescue StandardError
  "user_#{rng.int(1000, 99999)}"
end