Class: ColissimoFuelAdjustmentCoefficients

Inherits:
Object
  • Object
show all
Includes:
REXML
Defined in:
lib/colissimo_fuel_adjustment_coefficients.rb

Overview

Excepted XML is like:

<indice_gazole>
  <cap>
    <cap_mois>
      <titre>05-2017</titre>
      <routier>0,77%</routier>
      <aerien>0,00%</aerien>
    </cap_mois>
    ...
  </cap>
<indice_gazole>

Instance Method Summary collapse

Constructor Details

#initializeColissimoFuelAdjustmentCoefficients

Returns a new instance of ColissimoFuelAdjustmentCoefficients.



21
22
23
24
25
26
27
28
29
30
# File 'lib/colissimo_fuel_adjustment_coefficients.rb', line 21

def initialize
  @parsed_values = {}
  return unless xml_root

  caps  = xml_root.elements.first
  month = caps.elements.first
  month.elements.each do |element|
    @parsed_values[element.name] = element.text
  end
end

Instance Method Details

#air_multiplierObject



40
41
42
# File 'lib/colissimo_fuel_adjustment_coefficients.rb', line 40

def air_multiplier
  format_multiplier @parsed_values["aerien"]
end

#road_multiplierObject



44
45
46
# File 'lib/colissimo_fuel_adjustment_coefficients.rb', line 44

def road_multiplier
  format_multiplier @parsed_values["routier"]
end

#time_periodObject



36
37
38
# File 'lib/colissimo_fuel_adjustment_coefficients.rb', line 36

def time_period
  @parsed_values["titre"]
end

#urlObject



32
33
34
# File 'lib/colissimo_fuel_adjustment_coefficients.rb', line 32

def url
  "https://www.colissimo.entreprise.laposte.fr/fr/system/files/imagescontent/docs/indice_gazole.xml"
end