class DWML::DataExtractor
Attributes
element[R]
output[R]
Public Class Methods
new(element)
click to toggle source
# File lib/dwml/data_extractor.rb, line 9 def initialize(element) @element = element @locations = [] @time_layouts = [] @output = {} end
Public Instance Methods
process()
click to toggle source
# File lib/dwml/data_extractor.rb, line 16 def process extract_locations extract_time_layouts extract_parameters output end
Protected Instance Methods
extract_locations()
click to toggle source
# File lib/dwml/data_extractor.rb, line 26 def extract_locations @locations = Location.extract(element.xpath("location")) end
extract_parameters()
click to toggle source
# File lib/dwml/data_extractor.rb, line 34 def extract_parameters parameters = element.xpath("parameters") @output.merge!( :parameters => parameters.inject({}) do |memo, parameter| location = location_for_parameter(parameter) extractor = ParameterExtractor.new(parameter, location, @time_layouts) memo.merge!(location.location_key => extractor.process) memo end ) end
extract_time_layouts()
click to toggle source
# File lib/dwml/data_extractor.rb, line 30 def extract_time_layouts @time_layouts = TimeLayout.extract(element.xpath("time-layout")) end
location_for_parameter(parameter)
click to toggle source
# File lib/dwml/data_extractor.rb, line 47 def location_for_parameter(parameter) @locations.detect do |location| parameter.attributes["applicable-location"].text == location.location_key end end