Class: ChromeData::Vehicle
- Inherits:
-
BaseRequest
- Object
- BaseRequest
- ChromeData::Vehicle
- Defined in:
- lib/chrome_data/vehicle.rb
Defined Under Namespace
Classes: Engine
Instance Attribute Summary collapse
-
#division ⇒ Object
Returns the value of attribute division.
-
#engines ⇒ Object
Returns the value of attribute engines.
-
#model ⇒ Object
Returns the value of attribute model.
-
#model_year ⇒ Object
Returns the value of attribute model_year.
-
#styles ⇒ Object
Returns the value of attribute styles.
Class Method Summary collapse
Methods inherited from BaseRequest
build_request, client, endpoint_uri, find_elements, #initialize, make_request, request, wsdl_body
Constructor Details
This class inherits a constructor from ChromeData::BaseRequest
Instance Attribute Details
#division ⇒ Object
Returns the value of attribute division.
5 6 7 |
# File 'lib/chrome_data/vehicle.rb', line 5 def division @division end |
#engines ⇒ Object
Returns the value of attribute engines.
5 6 7 |
# File 'lib/chrome_data/vehicle.rb', line 5 def engines @engines end |
#model ⇒ Object
Returns the value of attribute model.
5 6 7 |
# File 'lib/chrome_data/vehicle.rb', line 5 def model @model end |
#model_year ⇒ Object
Returns the value of attribute model_year.
5 6 7 |
# File 'lib/chrome_data/vehicle.rb', line 5 def model_year @model_year end |
#styles ⇒ Object
Returns the value of attribute styles.
5 6 7 |
# File 'lib/chrome_data/vehicle.rb', line 5 def styles @styles end |
Class Method Details
.find_by_vin(vin) ⇒ Object
12 13 14 |
# File 'lib/chrome_data/vehicle.rb', line 12 def find_by_vin(vin) request 'vin' => vin end |
.parse_response(response) ⇒ Object
16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 |
# File 'lib/chrome_data/vehicle.rb', line 16 def parse_response(response) if vin_description = find_elements('vinDescription', response).first new.tap do |v| v.model_year = vin_description.attr('modelYear').to_i v.division = vin_description.attr('division') v.model = vin_description.attr('modelName') v.styles = find_elements('style', response).map do |e| Style.new( id: e.attr('id').to_i, name: e.attr('name'), trim: e.attr('trim'), name_without_trim: e.attr('nameWoTrim'), body_types: e.xpath("x:bodyType", 'x' => response.body.namespace.href).map do |bt| Style::BodyType.new(bt.attr('id').to_i, bt.text) end ) end v.engines = find_elements('engine', response).map do |e| Engine.new(e.at_xpath("x:engineType", 'x' => response.body.namespace.href).text) end end end end |
.request_name ⇒ Object
8 9 10 |
# File 'lib/chrome_data/vehicle.rb', line 8 def request_name "describeVehicle" end |