class Faker::Movies::StarWars
def quote(legacy_character = NOT_GIVEN, character: nil)
-
(String)
-
Parameters:
-
character
(String
) -- The name of a character to derive a quote from.
def quote(legacy_character = NOT_GIVEN, character: nil) warn_for_deprecated_arguments do |keywords| keywords << :character if legacy_character != NOT_GIVEN end quoted_characters = translate('faker.star_wars.quotes') if character.nil? character = sample(quoted_characters.keys).to_s else character = character.to_s.downcase # check alternate spellings, nicknames, titles of characters translate('faker.star_wars.alternate_character_spellings').each do |k, v| character = k.to_s if v.include?(character) end raise ArgumentError, "Character for quotes can be left blank or #{quoted_characters.keys.join(', ')}" unless quoted_characters.key?(character.to_sym) end fetch('star_wars.quotes.' + character) end