Class: TecDoc::VehicleManufacturer

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

Instance Attribute Summary collapse

Class Method Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(attributes = {}) ⇒ VehicleManufacturer

Returns a new instance of VehicleManufacturer.



34
35
36
37
# File 'lib/tec_doc/vehicle_manufacturer.rb', line 34

def initialize(attributes = {})
  @id = attributes[:manu_id].to_i
  @name = attributes[:manu_name].to_s
end

Instance Attribute Details

#idObject

Returns the value of attribute id.



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

def id
  @id
end

#nameObject

Returns the value of attribute name.



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

def name
  @name
end

#scopeObject

Returns the value of attribute scope.



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

def scope
  @scope
end

Class Method Details

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

Get all vehicle manufacturers

Parameters:

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

    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

Returns:



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

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_manufacturers3, options)
  response.map do |attributes|
    manufacturer = new
    manufacturer.scope = options
    manufacturer.id = attributes[:manu_id].to_i
    manufacturer.name = attributes[:manu_name].to_s
    manufacturer
  end
end

Instance Method Details

#models(options = {}) ⇒ Object

Get all models that manufacturer has made

Parameters:

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

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



42
43
44
# File 'lib/tec_doc/vehicle_manufacturer.rb', line 42

def models(options = {})
  VehicleModel.all(scope.merge(options.merge(:manu_id => id)))
end