Class: Tgios::XMLParser

Inherits:
Object
  • Object
show all
Defined in:
lib/tgios/xml_parser.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initializeXMLParser

Returns a new instance of XMLParser.



6
7
8
9
10
# File 'lib/tgios/xml_parser.rb', line 6

def initialize
  @nsxmlparser = nil
  @events = {}
  @key = nil
end

Instance Attribute Details

#s3_keyObject (readonly)

Returns the value of attribute s3_key.



4
5
6
# File 'lib/tgios/xml_parser.rb', line 4

def s3_key
  @s3_key
end

Instance Method Details

#delegate_parserObject



21
22
23
24
25
26
# File 'lib/tgios/xml_parser.rb', line 21

def delegate_parser
  @nsxmlparser.delegate = self
  @nsxmlparser.parse
  s3_key = @nsxmlparser.delegate.s3_key
  @events[:delegate].call(s3_key) unless @events[:delegate].nil?
end

#parse_xml(nsxmlparser_object, key_name, event_name, &block) ⇒ Object



12
13
14
15
16
17
18
19
# File 'lib/tgios/xml_parser.rb', line 12

def parse_xml(nsxmlparser_object,key_name,event_name, &block)
  @nsxmlparser = nsxmlparser_object
  @key = key_name
  @events[event_name] = block

  delegate_parser
  self
end

#parser(parser, foundCharacters: string) ⇒ Object



28
29
30
31
32
33
34
# File 'lib/tgios/xml_parser.rb', line 28

def parser(parser, didStartElement:elementName, namespaceURI:namespaceURI, qualifiedName:qualifiedName, attributes:attributeDict)
  if elementName == @key
    @scan_key = true
    @s3_key = ''

  end
end