Class: Faker::Movies::StarWars

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

Constant Summary

Constants inherited from Base

Base::Letters, 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_numberObject



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

def call_number
  sample(call_numbers)
end

.call_numbersObject



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

def call_numbers
  fetch_all('star_wars.call_numbers')
end

.call_signObject



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

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

.call_squadronObject



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

def call_squadron
  sample(call_squadrons)
end

.call_squadronsObject



72
73
74
# File 'lib/faker/movies/star_wars.rb', line 72

def call_squadrons
  fetch_all('star_wars.call_squadrons')
end

.characterObject



19
20
21
# File 'lib/faker/movies/star_wars.rb', line 19

def character
  sample(characters)
end

.charactersObject



76
77
78
# File 'lib/faker/movies/star_wars.rb', line 76

def characters
  fetch_all('star_wars.characters')
end

.droidObject



23
24
25
# File 'lib/faker/movies/star_wars.rb', line 23

def droid
  sample(droids)
end

.droidsObject



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

def droids
  fetch_all('star_wars.droids')
end

.planetObject



27
28
29
# File 'lib/faker/movies/star_wars.rb', line 27

def planet
  sample(planets)
end

.planetsObject



84
85
86
# File 'lib/faker/movies/star_wars.rb', line 84

def planets
  fetch_all('star_wars.planets')
end

.quote(character = nil) ⇒ Object



47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
# File 'lib/faker/movies/star_wars.rb', line 47

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

    unless quoted_characters.key?(character.to_sym)
      raise ArgumentError, "Character for quotes can be left blank or #{quoted_characters.keys.join(', ')}"
    end
  end

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

.specieObject



31
32
33
# File 'lib/faker/movies/star_wars.rb', line 31

def specie
  sample(species)
end

.speciesObject



88
89
90
# File 'lib/faker/movies/star_wars.rb', line 88

def species
  fetch_all('star_wars.species')
end

.vehicleObject



35
36
37
# File 'lib/faker/movies/star_wars.rb', line 35

def vehicle
  sample(vehicles)
end

.vehiclesObject



92
93
94
# File 'lib/faker/movies/star_wars.rb', line 92

def vehicles
  fetch_all('star_wars.vehicles')
end

.wookiee_sentenceObject Also known as: wookie_sentence



39
40
41
42
43
44
45
# File 'lib/faker/movies/star_wars.rb', line 39

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



96
97
98
# File 'lib/faker/movies/star_wars.rb', line 96

def wookiee_words
  fetch_all('star_wars.wookiee_words')
end