Class: Edmunds::Vehicle::Specification::Color::ColorsByStyle
- Inherits:
-
Object
- Object
- Edmunds::Vehicle::Specification::Color::ColorsByStyle
- Defined in:
- lib/edmunds/vehicle/specification/color.rb
Instance Attribute Summary collapse
-
#colors ⇒ Object
readonly
Returns the value of attribute colors.
-
#count ⇒ Object
readonly
Returns the value of attribute count.
Class Method Summary collapse
Instance Method Summary collapse
-
#initialize(attributes) ⇒ ColorsByStyle
constructor
A new instance of ColorsByStyle.
Constructor Details
#initialize(attributes) ⇒ ColorsByStyle
Returns a new instance of ColorsByStyle.
15 16 17 18 |
# File 'lib/edmunds/vehicle/specification/color.rb', line 15 def initialize(attributes) @colors = attributes['colors'].map { |json| ColorsDetails.new(json) } if attributes.key?('colors') @count = attributes['colorsCount'] end |
Instance Attribute Details
#colors ⇒ Object (readonly)
Returns the value of attribute colors.
13 14 15 |
# File 'lib/edmunds/vehicle/specification/color.rb', line 13 def colors @colors end |
#count ⇒ Object (readonly)
Returns the value of attribute count.
13 14 15 |
# File 'lib/edmunds/vehicle/specification/color.rb', line 13 def count @count end |
Class Method Details
.find(style_id, api_params = {}) ⇒ Object
20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 |
# File 'lib/edmunds/vehicle/specification/color.rb', line 20 def self.find(style_id, api_params = {}) response = Edmunds::Api.get("#{STYLE_API_URL}/#{style_id}/colors") do |request| request.raw_parameters = api_params request.allowed_parameters = { category: %w[Interior Exterior], fmt: %w[json] } request.default_parameters = { fmt: 'json' } request.required_parameters = %w[fmt] end attributes = JSON.parse(response.body) new(attributes) end |