Class: Faker::Vehicle
Constant Summary collapse
- MILEAGE_MIN =
10_000- MILEAGE_MAX =
90_000- VIN_LETTERS =
'ABCDEFGHJKLMNPRSTUVWXYZ'- VIN_MAP =
'0123456789X'- VIN_WEIGHTS =
'8765432X098765432'- VIN_REGEX =
/^([A-HJ-NPR-Z0-9]){3}[A-HJ-NPR-Z0-9]{5}[A-HJ-NPR-Z0-9]{1}[A-HJ-NPR-Z0-9]{1}[A-HJ-NPR-Z0-9]{1}[A-HJ-NPR-Z0-9]{1}\d{5}$/.freeze
- SG_CHECKSUM_WEIGHTS =
[3, 14, 2, 12, 2, 11, 1].freeze
- SG_CHECKSUM_CHARS =
'AYUSPLJGDBZXTRMKHEC'
Constants inherited from Base
Base::LLetters, Base::Letters, Base::NOT_GIVEN, Base::Numbers, Base::ULetters
Class Method Summary collapse
-
.car_options ⇒ Array<String>
Produces a random list of car options.
-
.car_type ⇒ String
Produces a random car type.
-
.color ⇒ String
Produces a random vehicle color.
-
.doors ⇒ Integer
(also: door_count)
Produces a random vehicle door count.
-
.drive_type ⇒ String
Produces a random vehicle drive type.
-
.engine ⇒ String
(also: engine_size)
Produces a random engine cylinder count.
-
.fuel_type ⇒ String
Produces a random vehicle fuel type.
-
.license_plate(state_abbreviation: '') ⇒ String
Produces a random license plate number.
-
.make ⇒ String
Produces a random vehicle make.
-
.make_and_model ⇒ String
Produces a random vehicle make and model.
-
.manufacture ⇒ String
Produces a random vehicle manufacturer.
-
.mileage(min: MILEAGE_MIN, max: MILEAGE_MAX) ⇒ Integer
(also: kilometrage)
Produces a random mileage/kilometrage for a vehicle.
-
.model(make_of_model: '') ⇒ String
Produces a random vehicle model.
-
.singapore_license_plate ⇒ String
Produces a random license plate number for Singapore.
-
.standard_specs ⇒ Array<String>
Produces a random list of standard specs.
-
.style ⇒ String
Produces a random vehicle style.
-
.transmission ⇒ String
Produces a random vehicle transmission.
-
.version ⇒ String
Produces a car version.
-
.vin ⇒ String
Produces a random vehicle VIN number.
-
.year ⇒ Integer
Produces a random car year between 1 and 15 years ago.
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
.car_options ⇒ Array<String>
Produces a random list of car options.
189 190 191 |
# File 'lib/faker/default/vehicle.rb', line 189 def Array.new(rand(5...10)) { fetch('vehicle.car_options') } end |
.car_type ⇒ String
Produces a random car type.
160 161 162 |
# File 'lib/faker/default/vehicle.rb', line 160 def car_type fetch('vehicle.car_types') end |
.color ⇒ String
Produces a random vehicle color.
108 109 110 |
# File 'lib/faker/default/vehicle.rb', line 108 def color fetch('vehicle.colors') end |
.doors ⇒ Integer Also known as: door_count
Produces a random vehicle door count.
216 217 218 |
# File 'lib/faker/default/vehicle.rb', line 216 def doors sample(fetch_all('vehicle.doors')) end |
.drive_type ⇒ String
Produces a random vehicle drive type.
134 135 136 |
# File 'lib/faker/default/vehicle.rb', line 134 def drive_type fetch('vehicle.drive_types') end |
.engine ⇒ String Also known as: engine_size
Produces a random engine cylinder count.
174 175 176 |
# File 'lib/faker/default/vehicle.rb', line 174 def engine "#{sample(fetch_all('vehicle.doors'))} #{fetch('vehicle.cylinder_engine')}" end |
.fuel_type ⇒ String
Produces a random vehicle fuel type.
147 148 149 |
# File 'lib/faker/default/vehicle.rb', line 147 def fuel_type fetch('vehicle.fuel_types') end |
.license_plate(state_abbreviation: '') ⇒ String
Produces a random license plate number.
265 266 267 268 269 270 |
# File 'lib/faker/default/vehicle.rb', line 265 def license_plate(state_abbreviation: '') return regexify(bothify(fetch('vehicle.license_plate'))) if state_abbreviation.empty? key = "vehicle.license_plate_by_state.#{state_abbreviation}" regexify(bothify(fetch(key))) end |
.make ⇒ String
Produces a random vehicle make.
50 51 52 |
# File 'lib/faker/default/vehicle.rb', line 50 def make fetch('vehicle.makes') end |
.make_and_model ⇒ String
Produces a random vehicle make and model.
80 81 82 83 84 |
# File 'lib/faker/default/vehicle.rb', line 80 def make_and_model m = make "#{m} #{model(make_of_model: m)}" end |
.manufacture ⇒ String
Produces a random vehicle manufacturer.
37 38 39 |
# File 'lib/faker/default/vehicle.rb', line 37 def manufacture fetch('vehicle.manufacture') end |
.mileage(min: MILEAGE_MIN, max: MILEAGE_MAX) ⇒ Integer Also known as: kilometrage
Produces a random mileage/kilometrage for a vehicle.
248 249 250 |
# File 'lib/faker/default/vehicle.rb', line 248 def mileage(min: MILEAGE_MIN, max: MILEAGE_MAX) rand_in_range(min, max) end |
.model(make_of_model: '') ⇒ String
Produces a random vehicle model.
65 66 67 68 69 |
# File 'lib/faker/default/vehicle.rb', line 65 def model(make_of_model: '') return fetch("vehicle.models_by_make.#{make}") if make_of_model.empty? fetch("vehicle.models_by_make.#{make_of_model}") end |
.singapore_license_plate ⇒ String
Produces a random license plate number for Singapore.
281 282 283 284 285 |
# File 'lib/faker/default/vehicle.rb', line 281 def singapore_license_plate key = 'vehicle.license_plate' plate_number = regexify(bothify(fetch(key))) "#{plate_number}#{singapore_checksum(plate_number)}" end |
.standard_specs ⇒ Array<String>
Produces a random list of standard specs.
202 203 204 |
# File 'lib/faker/default/vehicle.rb', line 202 def standard_specs Array.new(rand(5...10)) { fetch('vehicle.standard_specs') } end |
.style ⇒ String
Produces a random vehicle style.
95 96 97 |
# File 'lib/faker/default/vehicle.rb', line 95 def style fetch('vehicle.styles') end |
.transmission ⇒ String
Produces a random vehicle transmission.
121 122 123 |
# File 'lib/faker/default/vehicle.rb', line 121 def transmission fetch('vehicle.transmissions') end |
.version ⇒ String
Produces a car version
296 297 298 |
# File 'lib/faker/default/vehicle.rb', line 296 def version fetch('vehicle.version') end |