Class: NationalRailWrapper::Feeds::KnowledgeBase::Parsers::Tocs
- Inherits:
-
Object
- Object
- NationalRailWrapper::Feeds::KnowledgeBase::Parsers::Tocs
- Defined in:
- lib/national_rail_wrapper/feeds/knowledge_base/parsers/tocs.rb
Instance Method Summary collapse
-
#initialize(data) ⇒ Tocs
constructor
A new instance of Tocs.
- #to_json ⇒ Object
Constructor Details
#initialize(data) ⇒ Tocs
Returns a new instance of Tocs.
6 7 8 |
# File 'lib/national_rail_wrapper/feeds/knowledge_base/parsers/tocs.rb', line 6 def initialize(data) @data = data end |
Instance Method Details
#to_json ⇒ Object
10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 |
# File 'lib/national_rail_wrapper/feeds/knowledge_base/parsers/tocs.rb', line 10 def to_json = Nokogiri::XML::ParseOptions.new.nonet.noent.noblanks.huge doc = Nokogiri::XML.parse(@data, nil, nil, ) doc.xpath('/xmlns:TrainOperatingCompanyList/xmlns:TrainOperatingCompany').map do |toc_node| { name: toc_node.css('Name')&.text, atoc_code: toc_node.css('AtocCode')&.text, atoc_member: toc_node.css('AtocMember')&.text, legal_name: toc_node.css('LegalName')&.text, station_operator: toc_node.css('LegalName')&.text, managing_director: toc_node.css('ManagingDirector')&.text, logo: toc_node.css('Logo')&.text, network_map: toc_node.css('NetworkMap')&.text, company_website: toc_node.css('CompanyWebsite')&.text } end end |