module FFaker::String

def process_token(tokens)

Experimental RBS support (using type sampling data from the type_fusion project).

def process_token: (Array[] tokens) -> String

This signature was generated using 1 sample from 1 application.

def process_token(tokens)
  return '' if tokens.empty?
  token = tokens.shift
  case token
  when '?'
    # TODO: Let ? generate nothing
    '' # We already printed its target
  when '+'
    tokens.unshift(token) if rand(0..1) == 1 # Leave the `+` on to run again
    process_token(@last_token) # Run the last one at least once
  when '*'
    tokens.unshift(token) if rand(0..1) == 1 # Leave the `*` on to run again
    return '' if rand(0..1) == 1 # Or maybe do nothing
    process_token(@last_token) # Else run the last one again
  when '{'
    number = +''
    while (ch = tokens.shift) != '}'
      number << ch
    end
    number = number.to_i - 1
    t = @last_token.dup
    Array.new(number) { process_token(t.dup) }.join
  else
    generate_token token, tokens
  end
end