Class: ChronopostFuelMultiplier

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

Constant Summary collapse

URL =
'http://www.chronopost.fr/fr/surcharge-carburant'

Instance Method Summary collapse

Constructor Details

#initializeChronopostFuelMultiplier

Returns a new instance of ChronopostFuelMultiplier.



10
11
12
13
# File 'lib/chronopost_fuel_multiplier.rb', line 10

def initialize
  response = PlainHttpClient.get(url, limit: 3, timeout: 10)
  @page = Nokogiri::HTML response.body
end

Instance Method Details

#air_multiplierObject



19
20
21
# File 'lib/chronopost_fuel_multiplier.rb', line 19

def air_multiplier
  "%.4f" % (@page.at_css("table.ch-table tbody tr:last-child td:last-child").text.to_f / 100 + 1)
end

#road_multiplierObject



23
24
25
# File 'lib/chronopost_fuel_multiplier.rb', line 23

def road_multiplier
  "%.4f" % (@page.at_css("table.ch-table tbody tr td:last-child").text.to_f / 100 + 1)
end

#time_periodObject



15
16
17
# File 'lib/chronopost_fuel_multiplier.rb', line 15

def time_period
  @page.at_css("table.ch-table thead tr th:last-child").text
end

#urlObject



27
28
29
# File 'lib/chronopost_fuel_multiplier.rb', line 27

def url
  URL
end