Class: RailFeeds::NationalRail::HTTPClient

Inherits:
HTTPClient
  • Object
show all
Defined in:
lib/rail_feeds/national_rail/http_client.rb

Overview

A wrapper class for ::Net::HTTP

Instance Method Summary collapse

Methods inherited from HTTPClient

#download, #fetch_unzipped

Methods included from Logging

formatter, included, #logger, logger, #logger=, logger=

Constructor Details

#initialize(credentials: nil, **args) ⇒ HTTPClient

Returns a new instance of HTTPClient.



7
8
9
10
# File 'lib/rail_feeds/national_rail/http_client.rb', line 7

def initialize(credentials: nil, **args)
  credentials ||= RailFeeds::NationalRail::Credentials
  super
end

Instance Method Details

#fetch(path) { ... } ⇒ Object

Fetch path from server.

Parameters:

  • path (String)

    The path to fetch.

Yields:

  • contents @yieldparam [IO] file Either a Tempfile or StringIO.



16
17
18
# File 'lib/rail_feeds/national_rail/http_client.rb', line 16

def fetch(path)
  super "https://opendata.nationalrail.co.uk/#{path}", 'X-Auth-Token' => auth_token
end