Class: Faker::Books::Dune

Inherits:
Faker::Base show all
Defined in:
lib/faker/books/dune.rb

Constant Summary

Constants inherited from Faker::Base

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

Class Method Summary collapse

Methods inherited from Faker::Base

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

Class Method Details

.characterObject

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


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

def character
  fetch('dune.characters')
end

.planetObject


18
19
20
# File 'lib/faker/books/dune.rb', line 18

def planet
  fetch('dune.planets')
end

.quote(character = nil) ⇒ Object


22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
# File 'lib/faker/books/dune.rb', line 22

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

  if character.nil?
    character = sample(quoted_characters).to_s
  else
    character = 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

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

.saying(source = nil) ⇒ Object


39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
# File 'lib/faker/books/dune.rb', line 39

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

  if source.nil?
    source = sample(sourced_sayings).to_s
  else
    source = 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

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

.titleObject


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

def title
  fetch('dune.titles')
end