Class: AdfBuilder::ColorCombinations

Inherits:
Object
  • Object
show all
Defined in:
lib/adf_builder/vehicles/colorcombinations.rb

Constant Summary collapse

FREE_TEXT_OPTIONAL_TAGS =
[:interiorcolor, :exteriorcolor, :preference]

Instance Method Summary collapse

Constructor Details

#initialize(vehicle) ⇒ ColorCombinations

Returns a new instance of ColorCombinations.



6
7
8
9
# File 'lib/adf_builder/vehicles/colorcombinations.rb', line 6

def initialize(vehicle)
  @vehicle = vehicle
  @color_combination = nil
end

Instance Method Details

#add(interior_color, exterior_color, preference) ⇒ Object



11
12
13
14
15
16
17
18
# File 'lib/adf_builder/vehicles/colorcombinations.rb', line 11

def add(interior_color, exterior_color, preference)
  @color_combination = Ox::Element.new('colorcombination')
  @color_combination <<
    (Ox::Element.new('interiorcolor') << interior_color) <<
    (Ox::Element.new('exteriorcolor') << exterior_color) <<
    (Ox::Element.new('preference') << preference.to_s)
   @vehicle << @color_combination
end

#update_tags(index, tags) ⇒ Object



20
21
22
23
24
25
26
27
28
29
# File 'lib/adf_builder/vehicles/colorcombinations.rb', line 20

def update_tags(index, tags)
  valid, vehicle = AdfBuilder::Builder.valid_child?(@vehicle,'colorcombination', index)
  if valid
    tags.each do |key, value|
      if FREE_TEXT_OPTIONAL_TAGS.include? key.to_sym
        AdfBuilder::Builder.update_node(vehicle, key, value)
      end
    end
  end
end