Class: TecDoc::Vehicle
- Inherits:
-
Object
- Object
- TecDoc::Vehicle
- Defined in:
- lib/tec_doc/vehicle.rb
Instance Attribute Summary collapse
-
#article_link_id ⇒ Object
Returns the value of attribute article_link_id.
-
#attributes ⇒ Object
Returns the value of attribute attributes.
-
#cylinder_capacity ⇒ Object
Returns the value of attribute cylinder_capacity.
-
#date_of_construction_from ⇒ Object
Returns the value of attribute date_of_construction_from.
-
#date_of_construction_to ⇒ Object
Returns the value of attribute date_of_construction_to.
-
#first_country ⇒ Object
Returns the value of attribute first_country.
-
#fuel_type ⇒ Object
Returns the value of attribute fuel_type.
-
#fuel_type_process ⇒ Object
Returns the value of attribute fuel_type_process.
-
#id ⇒ Object
Returns the value of attribute id.
-
#linked ⇒ Object
Returns the value of attribute linked.
-
#manu_id ⇒ Object
Returns the value of attribute manu_id.
-
#mod_id ⇒ Object
Returns the value of attribute mod_id.
-
#motor_codes ⇒ Object
Returns the value of attribute motor_codes.
-
#name ⇒ Object
Returns the value of attribute name.
-
#power_hp_from ⇒ Object
Returns the value of attribute power_hp_from.
-
#power_hp_to ⇒ Object
Returns the value of attribute power_hp_to.
-
#power_kw_from ⇒ Object
Returns the value of attribute power_kw_from.
-
#power_kw_to ⇒ Object
Returns the value of attribute power_kw_to.
Class Method Summary collapse
-
.all(options = {}) ⇒ Array<TecDoc::VehicleManufacturer>
Find vehicles for simplified selection with motor codes.
- .find(options = {}) ⇒ Object
Instance Method Summary collapse
-
#assembly_groups(options = {}) ⇒ Object
Vehicle linked assembly parent groups.
Instance Attribute Details
#article_link_id ⇒ Object
Returns the value of attribute article_link_id.
3 4 5 |
# File 'lib/tec_doc/vehicle.rb', line 3 def article_link_id @article_link_id end |
#attributes ⇒ Object
Returns the value of attribute attributes.
3 4 5 |
# File 'lib/tec_doc/vehicle.rb', line 3 def attributes @attributes end |
#cylinder_capacity ⇒ Object
Returns the value of attribute cylinder_capacity.
3 4 5 |
# File 'lib/tec_doc/vehicle.rb', line 3 def cylinder_capacity @cylinder_capacity end |
#date_of_construction_from ⇒ Object
Returns the value of attribute date_of_construction_from.
3 4 5 |
# File 'lib/tec_doc/vehicle.rb', line 3 def date_of_construction_from @date_of_construction_from end |
#date_of_construction_to ⇒ Object
Returns the value of attribute date_of_construction_to.
3 4 5 |
# File 'lib/tec_doc/vehicle.rb', line 3 def date_of_construction_to @date_of_construction_to end |
#first_country ⇒ Object
Returns the value of attribute first_country.
3 4 5 |
# File 'lib/tec_doc/vehicle.rb', line 3 def first_country @first_country end |
#fuel_type ⇒ Object
Returns the value of attribute fuel_type.
3 4 5 |
# File 'lib/tec_doc/vehicle.rb', line 3 def fuel_type @fuel_type end |
#fuel_type_process ⇒ Object
Returns the value of attribute fuel_type_process.
3 4 5 |
# File 'lib/tec_doc/vehicle.rb', line 3 def fuel_type_process @fuel_type_process end |
#id ⇒ Object
Returns the value of attribute id.
3 4 5 |
# File 'lib/tec_doc/vehicle.rb', line 3 def id @id end |
#linked ⇒ Object
Returns the value of attribute linked.
3 4 5 |
# File 'lib/tec_doc/vehicle.rb', line 3 def linked @linked end |
#manu_id ⇒ Object
Returns the value of attribute manu_id.
3 4 5 |
# File 'lib/tec_doc/vehicle.rb', line 3 def manu_id @manu_id end |
#mod_id ⇒ Object
Returns the value of attribute mod_id.
3 4 5 |
# File 'lib/tec_doc/vehicle.rb', line 3 def mod_id @mod_id end |
#motor_codes ⇒ Object
Returns the value of attribute motor_codes.
3 4 5 |
# File 'lib/tec_doc/vehicle.rb', line 3 def motor_codes @motor_codes end |
#name ⇒ Object
Returns the value of attribute name.
3 4 5 |
# File 'lib/tec_doc/vehicle.rb', line 3 def name @name end |
#power_hp_from ⇒ Object
Returns the value of attribute power_hp_from.
3 4 5 |
# File 'lib/tec_doc/vehicle.rb', line 3 def power_hp_from @power_hp_from end |
#power_hp_to ⇒ Object
Returns the value of attribute power_hp_to.
3 4 5 |
# File 'lib/tec_doc/vehicle.rb', line 3 def power_hp_to @power_hp_to end |
#power_kw_from ⇒ Object
Returns the value of attribute power_kw_from.
3 4 5 |
# File 'lib/tec_doc/vehicle.rb', line 3 def power_kw_from @power_kw_from end |
#power_kw_to ⇒ Object
Returns the value of attribute power_kw_to.
3 4 5 |
# File 'lib/tec_doc/vehicle.rb', line 3 def power_kw_to @power_kw_to end |
Class Method Details
.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 |
.find(options = {}) ⇒ Object
68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 |
# File 'lib/tec_doc/vehicle.rb', line 68 def self.find( = {}) id = .delete(:id) = { :car_ids => { :array => { :ids => [id] } }, :countries_car_selection => TecDoc.client.country, :country_user_setting => TecDoc.client.country, :country => TecDoc.client.country, :lang => TecDoc.client.country, :axles => false, :cabs => false, :country_group_flag => false, :motor_codes => true, :vehicle_details_2 => false, :vehicle_terms => true }.merge() response = TecDoc.client.request(:get_vehicle_by_ids_2, ) if attrs = response.first details = attrs[:vehicle_details] || {} details2 = attrs[:vehicle_details2] || {} terms = attrs[:vehicle_terms] || {} vehicle = new vehicle.id = attrs[:car_id].to_i vehicle.name = terms[:car_type].to_s vehicle.cylinder_capacity = details[:ccm_tech].to_i vehicle.fuel_type = details2[:fuel_type].to_s vehicle.fuel_type_process = details2[:fuel_type_process].to_s vehicle.power_hp_from = details[:power_hp_from].to_i vehicle.power_hp_to = details[:power_hp_to].to_i vehicle.power_kw_from = details[:power_kw_from].to_i vehicle.power_kw_to = details[:power_kw_to].to_i vehicle.date_of_construction_from = DateParser.new(details[:year_of_constr_from]).to_date vehicle.date_of_construction_to = DateParser.new(details[:year_of_constr_to]).to_date vehicle.manu_id = details[:manu_id].to_i vehicle.mod_id = details[:mod_id].to_i vehicle.motor_codes = attrs[:motor_codes].map { |mc| mc[:motor_code] } vehicle else nil end end |
Instance Method Details
#assembly_groups(options = {}) ⇒ Object
Vehicle linked assembly parent groups
118 119 120 121 122 123 124 |
# File 'lib/tec_doc/vehicle.rb', line 118 def assembly_groups( = {}) .merge!({ :linking_target_type => "C", :linking_target_id => id, }) AssemblyGroup.all() end |