Method: Faker::Source.print

Defined in:
lib/faker/default/source.rb

Produces source code for printing a string in a given language.

Examples:

Faker::Source.print #=> "puts 'faker_string_to_print'"
Faker::Source.print(str: 'foo bar', lang: :javascript)
  #=> "console.log('foo bar');"

Available since:

  • 1.9.0



38
39
40
41
# File 'lib/faker/default/source.rb', line 38

def print(str: 'some string', lang: :ruby)
  code = fetch("source.print.#{lang}")
  code.gsub('faker_string_to_print', str)
end