Class: NationalRailWrapper::Feeds::KnowledgeBase::Parsers::NationalServiceIndicators
- Inherits:
-
Object
- Object
- NationalRailWrapper::Feeds::KnowledgeBase::Parsers::NationalServiceIndicators
- Defined in:
- lib/national_rail_wrapper/feeds/knowledge_base/parsers/national_service_indicators.rb
Instance Method Summary collapse
-
#initialize(data) ⇒ NationalServiceIndicators
constructor
A new instance of NationalServiceIndicators.
- #to_json ⇒ Object
Constructor Details
#initialize(data) ⇒ NationalServiceIndicators
Returns a new instance of NationalServiceIndicators.
6 7 8 |
# File 'lib/national_rail_wrapper/feeds/knowledge_base/parsers/national_service_indicators.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 |
# File 'lib/national_rail_wrapper/feeds/knowledge_base/parsers/national_service_indicators.rb', line 10 def to_json = Nokogiri::XML::ParseOptions.new.nonet.noent.noblanks doc = Nokogiri::XML.parse(@data, nil, nil, ) doc.xpath('/xmlns:NSI/xmlns:TOC').map do |toc_node| { toc_code: toc_node.xpath('./xmlns:TocCode').first&.content, toc_name: toc_node.xpath('./xmlns:TocName').first&.content, status: toc_node.xpath('./xmlns:Status').first&.content, status_image: toc_node.xpath('./xmlns:StatusImage').first&.content, status_description: toc_node.xpath('./xmlns:StatusDescription').first&.content, service_groups: service_groups(toc_node.xpath('./xmlns:ServiceGroup')), twitter_account: toc_node.xpath('./xmlns:TwitterAccount').first&.content, additional_info: toc_node.xpath('./xmlns:AdditionalInfo').first&.content, custom_additional_info: toc_node.xpath('./xmlns:CustomAdditionalInfo').first&.content } end end |