Class: FuelSurcharge::Colissimo

Inherits:
Object
  • Object
show all
Defined in:
lib/fuel_surcharge/colissimo.rb

Instance Method Summary collapse

Constructor Details

#initializeColissimo

Returns a new instance of Colissimo.



23
24
25
26
27
28
29
30
31
32
# File 'lib/fuel_surcharge/colissimo.rb', line 23

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



50
51
52
# File 'lib/fuel_surcharge/colissimo.rb', line 50

def air_multiplier
  air_percentage&.to_multiplier
end

#air_percentageObject



42
43
44
# File 'lib/fuel_surcharge/colissimo.rb', line 42

def air_percentage
  @parsed_values["aerien"]
end

#road_multiplierObject



54
55
56
# File 'lib/fuel_surcharge/colissimo.rb', line 54

def road_multiplier
  road_percentage&.to_multiplier
end

#road_percentageObject



46
47
48
# File 'lib/fuel_surcharge/colissimo.rb', line 46

def road_percentage
  @parsed_values["routier"]
end

#time_periodObject



38
39
40
# File 'lib/fuel_surcharge/colissimo.rb', line 38

def time_period
  @parsed_values["titre"]
end

#urlObject



34
35
36
# File 'lib/fuel_surcharge/colissimo.rb', line 34

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