Class: Faker::StarWars

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

Constant Summary

Constants inherited from Base

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

Class Method Summary collapse

Methods inherited from Base

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

Class Method Details

.call_numberObject


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

def call_number
  sample(call_numbers)
end

.call_numbersObject


44
45
46
# File 'lib/faker/star_wars.rb', line 44

def call_numbers
  fetch_all('star_wars.call_numbers')
end

.call_signObject


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

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

.call_squadronObject


4
5
6
# File 'lib/faker/star_wars.rb', line 4

def call_squadron
  sample(call_squadrons)
end

.call_squadronsObject


48
49
50
# File 'lib/faker/star_wars.rb', line 48

def call_squadrons
  fetch_all('star_wars.call_squadrons')
end

.characterObject


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

def character
  sample(characters)
end

.charactersObject


52
53
54
# File 'lib/faker/star_wars.rb', line 52

def characters
  fetch_all('star_wars.characters')
end

.droidObject


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

def droid
  sample(droids)
end

.droidsObject


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

def droids
  fetch_all('star_wars.droids')
end

.planetObject


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

def planet
  sample(planets)
end

.planetsObject


60
61
62
# File 'lib/faker/star_wars.rb', line 60

def planets
  fetch_all('star_wars.planets')
end

.quote(character = nil) ⇒ Object


64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
# File 'lib/faker/star_wars.rb', line 64

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

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


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

def specie
  sample(species)
end

.speciesObject


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

def species
  fetch_all('star_wars.species')
end

.vehicleObject


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

def vehicle
  sample(vehicles)
end

.vehiclesObject


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

def vehicles
  fetch_all('star_wars.vehicles')
end

.wookiee_sentenceObject Also known as: wookie_sentence


36
37
38
39
40
41
42
# File 'lib/faker/star_wars.rb', line 36

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


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

def wookiee_words
  fetch_all('star_wars.wookiee_words')
end