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, 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:

  • (String)

Available since:

  • 1.6.2


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

def call_number
  sample(call_numbers)
end

.call_numbersObject


164
165
166
# File 'lib/faker/movies/star_wars.rb', line 164

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:

  • (String)

Available since:

  • 1.6.2


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:

  • (String)

Available since:

  • 1.6.2


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

def call_squadron
  sample(call_squadrons)
end

.call_squadronsObject


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

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:

  • (String)

Available since:

  • 1.6.2


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

def character
  sample(characters)
end

.charactersObject


172
173
174
# File 'lib/faker/movies/star_wars.rb', line 172

def characters
  fetch_all('star_wars.characters')
end

.droidString

Produces a droid from Star Wars.

Examples:

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

Returns:

  • (String)

Available since:

  • 1.6.2


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

def droid
  sample(droids)
end

.droidsObject


176
177
178
# File 'lib/faker/movies/star_wars.rb', line 176

def droids
  fetch_all('star_wars.droids')
end

.planetString

Produces a planet from Star Wars.

Examples:

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

Returns:

  • (String)

Available since:

  • 1.6.2


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

def planet
  sample(planets)
end

.planetsObject


180
181
182
# File 'lib/faker/movies/star_wars.rb', line 180

def planets
  fetch_all('star_wars.planets')
end

.quote(legacy_character = NOT_GIVEN, 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:

  • (String)

Available since:

  • 1.6.2


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

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.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:

  • (String)

Available since:

  • 1.6.2


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

def specie
  sample(species)
end

.speciesObject


184
185
186
# File 'lib/faker/movies/star_wars.rb', line 184

def species
  fetch_all('star_wars.species')
end

.vehicleString

Produces a vehicle from Star Wars.

Examples:

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

Returns:

  • (String)

Available since:

  • 1.6.2


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

def vehicle
  sample(vehicles)
end

.vehiclesObject


188
189
190
# File 'lib/faker/movies/star_wars.rb', line 188

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:

  • (String)

Available since:

  • 1.6.2


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_wordsObject Also known as: wookie_words


192
193
194
# File 'lib/faker/movies/star_wars.rb', line 192

def wookiee_words
  fetch_all('star_wars.wookiee_words')
end