Module: RailFeeds::NationalRail::KnowledgeBase::NationalServiceIndicator

Defined in:
lib/rail_feeds/national_rail/knowledge_base/national_service_indicator.rb

Overview

A module for accessing the national service indicator from the national rail knowledge base.

Defined Under Namespace

Classes: ServiceGroup, Status, TOC

Class Method Summary collapse

Class Method Details

.download(file, credentials = Credentials) ⇒ Object

Download the current data.

Parameters:



35
36
37
38
# File 'lib/rail_feeds/national_rail/knowledge_base/national_service_indicator.rb', line 35

def self.download(file, credentials = Credentials)
  client = HTTPClient.new(credentials: credentials)
  client.download 'api/staticfeeds/4.0/serviceIndicators', file
end

.fetch(credentials = Credentials, &block) ⇒ IO

Fetch the current data.

Parameters:

Returns:

  • (IO)


43
44
45
46
# File 'lib/rail_feeds/national_rail/knowledge_base/national_service_indicator.rb', line 43

def self.fetch(credentials = Credentials, &block)
  client = HTTPClient.new(credentials: credentials)
  client.fetch 'api/staticfeeds/4.0/serviceIndicators', &block
end

.fetch_data(credentials = Credentials) ⇒ Object

Load data from the internet.

Parameters:

Returns:

  • Array<RailFeeds::NationalRail::KnowledgeBase::NationalServiceIndicator::TOC>


61
62
63
64
65
# File 'lib/rail_feeds/national_rail/knowledge_base/national_service_indicator.rb', line 61

def self.fetch_data(credentials = Credentials)
  fetch(credentials: credentials) do |file|
    parse_xml file.read
  end
end

.load_file(file) ⇒ Object

Load data from either a .json or .json.gz file.

Parameters:

  • file (String)

    The path of the file to open.

Returns:

  • Array<RailFeeds::NationalRail::KnowledgeBase::NationalServiceIndicator::TOC>


52
53
54
# File 'lib/rail_feeds/national_rail/knowledge_base/national_service_indicator.rb', line 52

def self.load_file(file)
  parse_xml File.read(file)
end