Class: Faker::Books::Dune

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

Overview

A Faker module beyond your dreams, test data beyond your imagination.

Constant Summary

Constants inherited from Faker::Base

Faker::Base::LLetters, Faker::Base::Letters, Faker::Base::NOT_GIVEN, 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

.characterString

Produces the name of a character from Dune

Examples:

Faker::Books::Dune.character #=> "Leto Atreides"

Returns:

  • (String)

Available since:

  • 1.9.3


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

def character
  fetch('dune.characters')
end

.cityString

Produces the name of a city from Dune

Examples:

Faker::Books::Dune.city #=> "Arrakeen"

Returns:

  • (String)

Available since:

  • next


42
43
44
# File 'lib/faker/books/dune.rb', line 42

def city
  fetch('dune.cities')
end

.planetString

Produces the name of a planet from Dune

Examples:

Faker::Books::Dune.planet #=> "Caladan"

Returns:

  • (String)

Available since:

  • 1.9.3


55
56
57
# File 'lib/faker/books/dune.rb', line 55

def planet
  fetch('dune.planets')
end

.quote(legacy_character = NOT_GIVEN, character: nil) ⇒ String

Produces a quote from Dune

Examples:

Faker::Books::Dune.quote
  #=> "A dead man, surely, no longer requires that water."
Faker::Books::Dune.quote(character: "baron_harkonnen")
  #=> "He who controls the spice, controls the universe!"

Parameters:

  • character (String) (defaults to: nil)

    The name of the character that the quote should be from

Returns:

  • (String)

Available since:

  • 1.9.3


74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
# File 'lib/faker/books/dune.rb', line 74

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.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(legacy_source = NOT_GIVEN, source: nil) ⇒ String

Produces a saying from Dune

Examples:

Faker::Books::Dune.saying #=> "You do not beg the sun for mercy."
Faker::Books::Dune.saying(source: "fremen")
  #=> "May thy knife chip and shatter."

Parameters:

  • source (String) (defaults to: nil)

Returns:

  • (String)

Available since:

  • 1.9.3


109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
# File 'lib/faker/books/dune.rb', line 109

def saying(legacy_source = NOT_GIVEN, source: nil)
  warn_for_deprecated_arguments do |keywords|
    keywords << :source if legacy_source != NOT_GIVEN
  end

  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

.titleString

Examples:

Faker::Books::Dune.title #=> "Duke"

Returns:

  • (String)

Available since:

  • 1.9.3


29
30
31
# File 'lib/faker/books/dune.rb', line 29

def title
  fetch('dune.titles')
end