Class: Edmunds::Vehicle::Specification::ModelYear::ModelYears
- Inherits:
-
Object
- Object
- Edmunds::Vehicle::Specification::ModelYear::ModelYears
- Defined in:
- lib/edmunds/vehicle/specification/model_year.rb
Instance Attribute Summary collapse
-
#count ⇒ Object
readonly
Returns the value of attribute count.
-
#model_years ⇒ Object
readonly
Returns the value of attribute model_years.
Class Method Summary collapse
Instance Method Summary collapse
-
#initialize(attributes) ⇒ ModelYears
constructor
A new instance of ModelYears.
Constructor Details
#initialize(attributes) ⇒ ModelYears
Returns a new instance of ModelYears.
45 46 47 48 |
# File 'lib/edmunds/vehicle/specification/model_year.rb', line 45 def initialize(attributes) @count = attributes['yearsCount'] @model_years = attributes['years'].map { |json| ModelYear.new(json) } if attributes.key?('years') end |
Instance Attribute Details
#count ⇒ Object (readonly)
Returns the value of attribute count.
43 44 45 |
# File 'lib/edmunds/vehicle/specification/model_year.rb', line 43 def count @count end |
#model_years ⇒ Object (readonly)
Returns the value of attribute model_years.
43 44 45 |
# File 'lib/edmunds/vehicle/specification/model_year.rb', line 43 def model_years @model_years end |
Class Method Details
.find(make_name, model_name, api_params = {}) ⇒ Object
50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 |
# File 'lib/edmunds/vehicle/specification/model_year.rb', line 50 def self.find(make_name, model_name, api_params = {}) response = Edmunds::Api.get("#{MODEL_API_URL}/#{make_name}/#{model_name}/years") do |request| request.raw_parameters = api_params request.allowed_parameters = { submodel: Edmunds::Vehicle::SUBMODEL_REGEX, category: Edmunds::Vehicle::VEHICLE_CATEGORIES, state: %w[new used future], year: ((1990.to_s)..(Date.current.year.to_s)), view: %w[basic full], fmt: %w[json] } request.default_parameters = { view: 'basic', fmt: 'json' } request.required_parameters = %w[fmt] end attributes = JSON.parse(response.body) new(attributes) end |