Module: Parking::Cars

Defined in:
lib/parking/cars.rb,
lib/parking/cars/ds.rb,
lib/parking/cars/mg.rb,
lib/parking/cars/bmw.rb,
lib/parking/cars/fso.rb,
lib/parking/cars/gaz.rb,
lib/parking/cars/kia.rb,
lib/parking/cars/ldv.rb,
lib/parking/cars/uaz.rb,
lib/parking/cars/zaz.rb,
lib/parking/cars/audi.rb,
lib/parking/cars/fiat.rb,
lib/parking/cars/ford.rb,
lib/parking/cars/jeep.rb,
lib/parking/cars/lada.rb,
lib/parking/cars/mini.rb,
lib/parking/cars/opel.rb,
lib/parking/cars/saab.rb,
lib/parking/cars/seat.rb,
lib/parking/cars/tata.rb,
lib/parking/cars/yugo.rb,
lib/parking/cars/acura.rb,
lib/parking/cars/aixam.rb,
lib/parking/cars/buick.rb,
lib/parking/cars/cupra.rb,
lib/parking/cars/dacia.rb,
lib/parking/cars/dodge.rb,
lib/parking/cars/geely.rb,
lib/parking/cars/honda.rb,
lib/parking/cars/isuzu.rb,
lib/parking/cars/iveco.rb,
lib/parking/cars/lexus.rb,
lib/parking/cars/lotus.rb,
lib/parking/cars/mazda.rb,
lib/parking/cars/qoros.rb,
lib/parking/cars/rover.rb,
lib/parking/cars/scion.rb,
lib/parking/cars/skoda.rb,
lib/parking/cars/smart.rb,
lib/parking/cars/tesla.rb,
lib/parking/cars/volvo.rb,
lib/parking/cars/abarth.rb,
lib/parking/cars/alpine.rb,
lib/parking/cars/daewoo.rb,
lib/parking/cars/hummer.rb,
lib/parking/cars/jaguar.rb,
lib/parking/cars/lancia.rb,
lib/parking/cars/ligier.rb,
lib/parking/cars/nissan.rb,
lib/parking/cars/proton.rb,
lib/parking/cars/subaru.rb,
lib/parking/cars/suzuki.rb,
lib/parking/cars/syrena.rb,
lib/parking/cars/talbot.rb,
lib/parking/cars/toyota.rb,
lib/parking/cars/bentley.rb,
lib/parking/cars/bugatti.rb,
lib/parking/cars/citroen.rb,
lib/parking/cars/ferrari.rb,
lib/parking/cars/hyundai.rb,
lib/parking/cars/intrall.rb,
lib/parking/cars/lincoln.rb,
lib/parking/cars/maybach.rb,
lib/parking/cars/mercury.rb,
lib/parking/cars/peugeot.rb,
lib/parking/cars/pontiac.rb,
lib/parking/cars/porsche.rb,
lib/parking/cars/renault.rb,
lib/parking/cars/trabant.rb,
lib/parking/cars/cadillac.rb,
lib/parking/cars/chatenet.rb,
lib/parking/cars/chrysler.rb,
lib/parking/cars/daihatsu.rb,
lib/parking/cars/infiniti.rb,
lib/parking/cars/landwind.rb,
lib/parking/cars/maserati.rb,
lib/parking/cars/mercedes.rb,
lib/parking/cars/microcar.rb,
lib/parking/cars/plymouth.rb,
lib/parking/cars/wartburg.rb,
lib/parking/cars/chevrolet.rb,
lib/parking/cars/de_lorean.rb,
lib/parking/cars/alfa_romeo.rb,
lib/parking/cars/land_rover.rb,
lib/parking/cars/mitsubishi.rb,
lib/parking/cars/ssang_yong.rb,
lib/parking/cars/volkswagen.rb,
lib/parking/cars/lamborghini.rb,
lib/parking/cars/rolls_royce.rb,
lib/parking/cars/aston_martin.rb

Defined Under Namespace

Classes: Abarth, Acura, Aixam, AlfaRomeo, Alpine, AstonMartin, Audi, Bentley, Bmw, Bugatti, Buick, Cadillac, Chatenet, Chevrolet, Chrysler, Citroen, Cupra, Dacia, Daewoo, Daihatsu, DeLorean, Dodge, Ds, Ferrari, Fiat, Ford, Fso, Gaz, Geely, Honda, Hummer, Hyundai, Infiniti, Intrall, Isuzu, Iveco, Jaguar, Jeep, Kia, Lada, Lamborghini, Lancia, LandRover, Landwind, Ldv, Lexus, Ligier, Lincoln, Lotus, Maserati, Maybach, Mazda, Mercedes, Mercury, Mg, Microcar, Mini, Mitsubishi, Nissan, Opel, Peugeot, Plymouth, Pontiac, Porsche, Proton, Qoros, Renault, RollsRoyce, Rover, Saab, Scion, Seat, Skoda, Smart, SsangYong, Subaru, Suzuki, Syrena, Talbot, Tata, Tesla, Toyota, Trabant, Uaz, Volkswagen, Volvo, Wartburg, Yugo, Zaz

Class Method Summary collapse

Class Method Details

.brandsObject



4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
# File 'lib/parking/cars.rb', line 4

def brands
  [
  'Abarth',
  'Acura',
  'Aixam',
  'Alfa Romeo',
  'Alpine',
  'Aston Martin',
  'Audi',
  'Bentley',
  'BMW',
  'Bugatti',
  'Buick',
  'Cadillac',
  'Chatenet',
  'Chevrolet',
  'Chrysler',
  'Citroen',
  'Cupra',
  'Dacia',
  'Daewoo',
  'Daihatsu',
  'DeLorean',
  'Dodge',
  'DS',
  'Ferrari',
  'Fiat',
  'Ford',
  'FSO',
  'GAZ',
  'Geely',
  'Honda',
  'Hummer',
  'Hyundai',
  'Infiniti',
  'Intrall',
  'Isuzu',
  'Iveco',
  'Jaguar',
  'Jeep',
  'Kia',
  'Lamborghini',
  'Lancia',
  'Land Rover',
  'Landwind',
  'LDV',
  'Lexus',
  'Ligier',
  'Lincoln',
  'Lotus',
  'Lada',
  'Maserati',
  'Maybach',
  'Mazda',
  'Mercedes',
  'Mercury',
  'MG',
  'Microcar',
  'Mini',
  'Mitsubishi',
  'Nissan',
  'Opel',
  'Peugeot',
  'Plymouth',
  'Pontiac',
  'Porsche',
  'Proton',
  'Qoros',
  'Renault',
  'Rolls-Royce',
  'Rover',
  'Saab',
  'Scion',
  'Seat',
  'Skoda',
  'Smart',
  'SsangYong',
  'Subaru',
  'Suzuki',
  'Syrena',
  'Talbot',
  'TATA',
  'Tesla',
  'Toyota',
  'Trabant',
  'UAZ',
  'Volkswagen',
  'Volvo',
  'Wartburg',
  'Yugo',
  'ZAZ'
]
end

.countriesObject



117
118
119
# File 'lib/parking/cars.rb', line 117

def countries
  brands.map { |brand| Object.const_get(class_name(brand)).country }.uniq
end

.method_missing(method, *args) ⇒ Object



104
105
106
107
108
109
110
111
112
113
114
115
# File 'lib/parking/cars.rb', line 104

def method_missing(method, *args)
  if method.to_s.start_with?('from')
    country = method.to_s.sub('from_', '')
    country.sub!('_', ' ')

    brands.map do |brand|
      brand_class = Object.const_get(class_name(brand))

      brand_class.name if brand_class.country.downcase == country
    end.compact
  end
end

.randomObject



98
99
100
101
102
# File 'lib/parking/cars.rb', line 98

def random
  brand_class = Object.const_get(class_name(brands.sample))

  "#{brand_class.name} #{brand_class.models.sample}"
end