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