Method: TecDoc::Vehicle.all
- Defined in:
- lib/tec_doc/vehicle.rb
.all(options = {}) ⇒ Array<TecDoc::VehicleManufacturer>
Find vehicles for simplified selection with motor codes
35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 |
# File 'lib/tec_doc/vehicle.rb', line 35 def self.all( = {}) = { :car_type => 1, :countries_car_selection => TecDoc.client.country, :country_group_flag => false, :favoured_list => 1, :lang => I18n.locale.to_s, :linked => false }.merge() response = TecDoc.client.request(:get_vehicle_simplified_selection4, ) response.map do |attributes| vehicle = new car_attributes = attributes[:car_details] if car_attributes vehicle.manu_id = [:manu_id].to_i vehicle.mod_id = [:mod_id].to_i vehicle.id = car_attributes[:car_id].to_i vehicle.name = car_attributes[:car_name].to_s vehicle.cylinder_capacity = car_attributes[:cylinder_capacity].to_i vehicle.first_country = car_attributes[:first_country].to_s vehicle.linked = car_attributes[:linked] vehicle.power_hp_from = car_attributes[:power_hp_from].to_i vehicle.power_hp_to = car_attributes[:power_hp_to].to_i vehicle.power_kw_from = car_attributes[:power_kw_from].to_i vehicle.power_kw_to = car_attributes[:power_kw_to].to_i vehicle.date_of_construction_from = DateParser.new(car_attributes[:year_of_constr_from]).to_date vehicle.date_of_construction_to = DateParser.new(car_attributes[:year_of_constr_to]).to_date end vehicle.motor_codes = attributes[:motor_codes].map { |mc| mc[:motor_code] } vehicle end end |