Method: Faker::Dune.saying

Defined in:
lib/faker/dune.rb

.saying(source = nil) ⇒ Object



36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
# File 'lib/faker/dune.rb', line 36

def saying(source = nil)
  sourced_sayings = translate('faker.dune.sayings').keys

  if source.nil?
    source = sample(sourced_sayings).to_s
  else
    source.to_s.downcase!

    unless sourced_sayings.include?(source.to_sym)
      raise ArgumentError,
        "Sources quoted in sayings can be left blank or #{sourced_sayings.join(', ')}"
    end
  end

  return fetch('dune.sayings.' + source)
end