Class: Faker::Dune

Inherits:
Base
  • Object
show all
Defined in:
lib/faker/dune.rb

Constant Summary

Constants inherited from Base

Base::Letters, Base::Numbers, Base::ULetters

Class Method Summary collapse

Methods inherited from Base

bothify, fetch, fetch_all, flexible, letterify, method_missing, numerify, parse, rand, rand_in_range, regexify, sample, shuffle, translate, unique, with_locale

Class Method Details

.characterObject

QUOTED_CHARACTERS = fetch(“dune.quotes”) SAYING_SOURCES = %w(translate(“faker.dune.sources”))



7
8
9
# File 'lib/faker/dune.rb', line 7

def character
  fetch('dune.characters')
end

.planetObject



15
16
17
# File 'lib/faker/dune.rb', line 15

def planet
  fetch('dune.planets')
end

.quote(character = nil) ⇒ Object



19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
# File 'lib/faker/dune.rb', line 19

def quote(character = nil)
  quoted_characters = translate('faker.dune.quotes').keys

  if character.nil?
    character = sample(quoted_characters).to_s
  else
    character.to_s.downcase!

    unless quoted_characters.include?(character.to_sym)
      raise ArgumentError,
        "Characters quoted can be left blank or #{quoted_characters.join(', ')}"
    end
  end

  return fetch('dune.quotes.' + character)
end

.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

.titleObject



11
12
13
# File 'lib/faker/dune.rb', line 11

def title
  fetch('dune.titles')
end