Class: Faker::Movies::StarWars

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

Constant Summary

Constants inherited from Base

Base::LLetters, Base::Letters, Base::NOT_GIVEN, Base::Numbers, Base::ULetters

Class Method Summary collapse

Methods inherited from Base

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

Class Method Details

.call_numberString

Produces a call number from Star Wars.

Examples:

Faker::Movies::StarWars.call_number #=> "Leader"

Returns:



42
43
44
# File 'lib/faker/movies/star_wars.rb', line 42

def call_number
  sample(call_numbers)
end

.call_numbersArray

Generates numbers array

Examples:

Faker::Movies::StarWars.call_numbers  #=> ["Leader", "#"]

Returns:

  • (Array)


169
170
171
# File 'lib/faker/movies/star_wars.rb', line 169

def call_numbers
  fetch_all('star_wars.call_numbers')
end

.call_signString

Produces a call sign from Star Wars.

Examples:

Faker::Movies::StarWars.call_sign #=> "Grey 5"

Returns:



29
30
31
# File 'lib/faker/movies/star_wars.rb', line 29

def call_sign
  numerify(parse('star_wars.call_sign'))
end

.call_squadronString

Produces a call squadron from Star Wars.

Examples:

Faker::Movies::StarWars.call_squadron #=> "Green"

Returns:



16
17
18
# File 'lib/faker/movies/star_wars.rb', line 16

def call_squadron
  sample(call_squadrons)
end

.call_squadronsArray

Returns squadrons array

Examples:

Faker::Movies::StarWars.call_squadrons  #=> ["Rogue", "Red", "Gray", "Green", "Blue", "Gold", "Black", "Yellow", "Phoenix"]

Returns:

  • (Array)


182
183
184
# File 'lib/faker/movies/star_wars.rb', line 182

def call_squadrons
  fetch_all('star_wars.call_squadrons')
end

.characterString

Produces a character from Star Wars.

Examples:

Faker::Movies::StarWars.character #=> "Anakin Skywalker"

Returns:



55
56
57
# File 'lib/faker/movies/star_wars.rb', line 55

def character
  sample(characters)
end

.charactersArray

Returns all character names in movie

Examples:

Faker::Movies::StarWars.characters

Returns:

  • (Array)


195
196
197
# File 'lib/faker/movies/star_wars.rb', line 195

def characters
  fetch_all('star_wars.characters')
end

.droidString

Produces a droid from Star Wars.

Examples:

Faker::Movies::StarWars.droid #=> "C-3PO"

Returns:



68
69
70
# File 'lib/faker/movies/star_wars.rb', line 68

def droid
  sample(droids)
end

.droidsArray

Returns droid list

Examples:

Faker::Movies::StarWars.droids

Returns:

  • (Array)


208
209
210
# File 'lib/faker/movies/star_wars.rb', line 208

def droids
  fetch_all('star_wars.droids')
end

.planetString

Produces a planet from Star Wars.

Examples:

Faker::Movies::StarWars.planet #=> "Tatooine"

Returns:



81
82
83
# File 'lib/faker/movies/star_wars.rb', line 81

def planet
  sample(planets)
end

.planetsArray

Lists out all planet names

Examples:

Faker::Movies::StarWars.planets

Returns:

  • (Array)


221
222
223
# File 'lib/faker/movies/star_wars.rb', line 221

def planets
  fetch_all('star_wars.planets')
end

.quote(character: nil) ⇒ String

Produces a quote from Star Wars.

Examples:

Faker::Movies::StarWars.quote #=> "Aren't you a little short for a Stormtrooper?"
Faker::Movies::StarWars.quote(character: "leia_organa")
  #=> "Aren't you a little short for a Stormtrooper?"

Parameters:

  • character (String) (defaults to: nil)

    The name of a character to derive a quote from.

Returns:



141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
# File 'lib/faker/movies/star_wars.rb', line 141

def quote(character: nil)
  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

.specieString

Produces a species from Star Wars.

Examples:

Faker::Movies::StarWars.specie #=> "Gungan"

Returns:



94
95
96
# File 'lib/faker/movies/star_wars.rb', line 94

def specie
  sample(species)
end

.speciesArray

Returns name of all species

Examples:

Faker::Movies::StarWars.species

Returns:

  • (Array)


234
235
236
# File 'lib/faker/movies/star_wars.rb', line 234

def species
  fetch_all('star_wars.species')
end

.vehicleString

Produces a vehicle from Star Wars.

Examples:

Faker::Movies::StarWars.vehicle #=> "Sandcrawler"

Returns:



107
108
109
# File 'lib/faker/movies/star_wars.rb', line 107

def vehicle
  sample(vehicles)
end

.vehiclesArray

Lists out all vehicles

Examples:

Faker::Movies::StarWars.vehicles

Returns:

  • (Array)


247
248
249
# File 'lib/faker/movies/star_wars.rb', line 247

def vehicles
  fetch_all('star_wars.vehicles')
end

.wookiee_sentenceString Also known as: wookie_sentence

Produces a wookiee sentence from Star Wars.

Examples:

Faker::Movies::StarWars.wookiee_sentence #=> "Yrroonn ru ooma roo ahuma ur roooarrgh hnn-rowr."

Returns:



119
120
121
122
123
124
125
# File 'lib/faker/movies/star_wars.rb', line 119

def wookiee_sentence
  sentence = sample(wookiee_words).capitalize

  rand(0..10).times { sentence += " #{sample(wookiee_words)}" }

  sentence + sample(['.', '?', '!'])
end

.wookiee_wordsArray Also known as: wookie_words

All wookiee words

Examples:

Faker::Movies::StarWars.wookiee_words

Returns:

  • (Array)


260
261
262
# File 'lib/faker/movies/star_wars.rb', line 260

def wookiee_words
  fetch_all('star_wars.wookiee_words')
end