Class: Edmunds::Vehicle::Specification::VinDecoding::Full
- Inherits:
-
Object
- Object
- Edmunds::Vehicle::Specification::VinDecoding::Full
- Defined in:
- lib/edmunds/vehicle/specification/vin_decoding.rb
Instance Attribute Summary collapse
-
#make ⇒ Object
readonly
Returns the value of attribute make.
-
#model ⇒ Object
readonly
Returns the value of attribute model.
-
#mpg_city ⇒ Object
readonly
Returns the value of attribute mpg_city.
-
#mpg_highway ⇒ Object
readonly
Returns the value of attribute mpg_highway.
-
#years ⇒ Object
readonly
Returns the value of attribute years.
Class Method Summary collapse
-
.find(vin, api_params = {}) ⇒ Basic
Get all vehicle details from make, model, year and fuel type to list of options, features and standard equipment.
Instance Method Summary collapse
-
#initialize(attributes) ⇒ Full
constructor
A new instance of Full.
Constructor Details
#initialize(attributes) ⇒ Full
Returns a new instance of Full.
13 14 15 16 17 18 19 |
# File 'lib/edmunds/vehicle/specification/vin_decoding.rb', line 13 def initialize(attributes) @make = Edmunds::Vehicle::Specification::Make::Make.new(attributes['make']) @model = Edmunds::Vehicle::Specification::Model::Model.new(attributes['model']) @years = attributes['years'].map { |json| Edmunds::Vehicle::Specification::ModelYear::ModelYear.new(json) } if attributes.key?('years') @mpg_highway = attributes['MPG']['highway'] @mpg_city = attributes['MPG']['city'] end |
Instance Attribute Details
#make ⇒ Object (readonly)
Returns the value of attribute make.
11 12 13 |
# File 'lib/edmunds/vehicle/specification/vin_decoding.rb', line 11 def make @make end |
#model ⇒ Object (readonly)
Returns the value of attribute model.
11 12 13 |
# File 'lib/edmunds/vehicle/specification/vin_decoding.rb', line 11 def model @model end |
#mpg_city ⇒ Object (readonly)
Returns the value of attribute mpg_city.
11 12 13 |
# File 'lib/edmunds/vehicle/specification/vin_decoding.rb', line 11 def mpg_city @mpg_city end |
#mpg_highway ⇒ Object (readonly)
Returns the value of attribute mpg_highway.
11 12 13 |
# File 'lib/edmunds/vehicle/specification/vin_decoding.rb', line 11 def mpg_highway @mpg_highway end |
#years ⇒ Object (readonly)
Returns the value of attribute years.
11 12 13 |
# File 'lib/edmunds/vehicle/specification/vin_decoding.rb', line 11 def years @years end |
Class Method Details
.find(vin, api_params = {}) ⇒ Basic
Get all vehicle details from make, model, year and fuel type to list of options, features and standard equipment. All this information is returned by decoding the vehicle’s VIN.
25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 |
# File 'lib/edmunds/vehicle/specification/vin_decoding.rb', line 25 def self.find(vin, api_params = {}) response = Edmunds::Api.get("#{FULL_API_URL}/#{vin}") do |request| request.raw_parameters = api_params request.allowed_parameters = { # OEM CODE fmt: %w[json] } request.default_parameters = {fmt: 'json' } request.required_parameters = %w[fmt] end attributes = JSON.parse(response.body) new(attributes) end |