Class: TecDoc::VehicleModel

Inherits:
Object
  • Object
show all
Defined in:
lib/tec_doc/vehicle_model.rb

Instance Attribute Summary collapse

Class Method Summary collapse

Instance Method Summary collapse

Instance Attribute Details

#date_of_construction_fromObject

Returns the value of attribute date_of_construction_from.



3
4
5
# File 'lib/tec_doc/vehicle_model.rb', line 3

def date_of_construction_from
  @date_of_construction_from
end

#date_of_construction_toObject

Returns the value of attribute date_of_construction_to.



3
4
5
# File 'lib/tec_doc/vehicle_model.rb', line 3

def date_of_construction_to
  @date_of_construction_to
end

#idObject

Returns the value of attribute id.



3
4
5
# File 'lib/tec_doc/vehicle_model.rb', line 3

def id
  @id
end

#nameObject

Returns the value of attribute name.



3
4
5
# File 'lib/tec_doc/vehicle_model.rb', line 3

def name
  @name
end

#scopeObject

Returns the value of attribute scope.



5
6
7
# File 'lib/tec_doc/vehicle_model.rb', line 5

def scope
  @scope
end

Class Method Details

.all(options) ⇒ Array<TecDoc::VehicleManufacturer>

Get all vehicle models

Parameters:

  • options (Hash)

    a customizable set of options

Options Hash (options):

  • :car_type (Integer)

    vehicle type (1: Passenger car, 2: Commercial vehicle, 3: Light commercial)

  • :countries_car_selection (String)

    country code according to ISO 3166

  • :country_group_flag (TrueClass, FalseClass)

    country group selection

  • :eval_favor (TrueClass, FalseClass)

    simplified Flag: simplified vehicle selection

  • :favoured_list (Integer, NilClass)

    simplified vehicle selection (1: first list selection, 0: rest) (optional)

  • :lang (String)

    language code according to ISO 639

  • :manu_id (Integer)

    manufacturer id

Returns:



17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
# File 'lib/tec_doc/vehicle_model.rb', line 17

def self.all(options)
  options = {
    :car_type => 1,
    :countries_car_selection => TecDoc.client.country,
    :country_group_flag => false,
    :eval_favor => false,
    :lang => I18n.locale.to_s
  }.merge(options)
  response = TecDoc.client.request(:get_vehicle_models3, options)
  response.map do |attributes|
    model = new
    model.scope = options
    model.id = attributes[:model_id].to_i
    model.name = attributes[:modelname].to_s
    model.date_of_construction_from = DateParser.new(attributes[:year_of_constr_from]).to_date
    model.date_of_construction_to = DateParser.new(attributes[:year_of_constr_to]).to_date
    model
  end
end

Instance Method Details

#vehicles(options = {}) ⇒ Object

Get all vehicles for this model

Parameters:

  • options (Hash) (defaults to: {})

    see ‘TecDoc::Vehicle.all` for available options



40
41
42
43
44
# File 'lib/tec_doc/vehicle_model.rb', line 40

def vehicles(options = {})
  options = scope.merge(options.merge(:mod_id => id))
  options.delete(:eval_favor)
  Vehicle.all(options)
end