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

destination[R]

Public Class Methods

new(destination_node) click to toggle source

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

history() click to toggle source

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
introduction() click to toggle source

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
practical_information() click to toggle source

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
to_hash() click to toggle source

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
transport() click to toggle source

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
weather() click to toggle source

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
work_live_study() click to toggle source

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