require 'rexml/document' require 'rexml/xpath' require 'cursor_vector' module CanControlsGateway class RawEvent attr_reader :vector, :event_type def initialize xml_node @xml_node = REXML::Document.new(xml_node.to_s) @vector = nil @event_type = nil parse_xml end private def parse_xml @event_type = REXML::XPath.first(@xml_node, "/event/attribute::type") @event_type = @event_type.value if @event_type my_vector_match = REXML::XPath.first(@xml_node, "/event/position") if my_vector_match @vector = CanControlsGateway::CursorVector.new(my_vector_match) end end end end