class TaxGenerator::Destination
class used to find xpaths from the destination node from xml
@!attribute destination
@return [Nokogiri::Element] the element from the xml document that need to be parsed
Attributes
Public Class Methods
receives destination node (xml element) that need to be parsed
@param [Nokogiri::Element] destination_node the element from the xml document that need to be parsed
@return [void]
@api public
# File lib/tax_generator/classes/destination.rb, line 22 def initialize(destination_node) @destination = destination_node end
Public Instance Methods
returns the information about the history
@return [Nokogiri::NodeSet]
@api public
# File lib/tax_generator/classes/destination.rb, line 40 def history xpath('./history/history/history') end
returns the information about the introduction
@return [Nokogiri::NodeSet]
@api public
# File lib/tax_generator/classes/destination.rb, line 31 def introduction xpath('.//introductory/introduction/overview') end
returns the information about the practical_information
@return [Nokogiri::NodeSet]
@api public
# File lib/tax_generator/classes/destination.rb, line 49 def practical_information base = './/practical_information/health_and_safety' xpath("#{base}/dangers_and_annoyances") + xpath("#{base}/while_youre_there") + \ xpath("#{base}/before_you_go") + xpath("#{base}/money_and_costs/money") end
returns the a hash containing all the parsed information from the xml document and makes sure that only elements with content not blank will be returned
@see elements_with_content
@return [Nokogiri::NodeSet]
@api public
# File lib/tax_generator/classes/destination.rb, line 89 def to_hash { introduction: introduction, history: history, practical_information: practical_information, transport: transport, weather: weather, work_live_study: work_live_study }.each_with_object({}) do |(key, value), hsh| hsh[key] = elements_with_content(value) hsh end end
returns the information about the transport
@return [Nokogiri::NodeSet]
@api public
# File lib/tax_generator/classes/destination.rb, line 60 def transport xpath('.//transport/getting_around') end
returns the information about the weather
@return [Nokogiri::NodeSet]
@api public
# File lib/tax_generator/classes/destination.rb, line 69 def weather xpath('.//weather') end
returns the information about the work_live_study
@return [Nokogiri::NodeSet]
@api public
# File lib/tax_generator/classes/destination.rb, line 78 def work_live_study xpath('.//work_live_study') end