Class: Archimate::FileFormats::Sax::Handler

Inherits:
Object
  • Object
show all
Defined in:
lib/archimate/file_formats/sax/handler.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(name, attrs, parent_handler) ⇒ Handler

Returns a new instance of Handler.



12
13
14
15
16
17
# File 'lib/archimate/file_formats/sax/handler.rb', line 12

def initialize(name, attrs, parent_handler)
  @name = name
  @attrs = Hash[attrs]
  @parent_handler = parent_handler
  @element_type = @attrs["xsi:type"]&.sub(/archimate:/, '')
end

Dynamic Method Handling

This class handles dynamic methods through the method_missing method

#method_missing(sym, *args) ⇒ Object



34
35
36
37
# File 'lib/archimate/file_formats/sax/handler.rb', line 34

def method_missing(sym, *args)
  return args.first if sym.to_s.start_with?("on_")
  super
end

Instance Attribute Details

#attrsObject (readonly)

Returns the value of attribute attrs.



8
9
10
# File 'lib/archimate/file_formats/sax/handler.rb', line 8

def attrs
  @attrs
end

#element_typeObject (readonly)

Returns the value of attribute element_type.



10
11
12
# File 'lib/archimate/file_formats/sax/handler.rb', line 10

def element_type
  @element_type
end

#nameObject (readonly)

Returns the value of attribute name.



7
8
9
# File 'lib/archimate/file_formats/sax/handler.rb', line 7

def name
  @name
end

#parent_handlerObject (readonly)

Returns the value of attribute parent_handler.



9
10
11
# File 'lib/archimate/file_formats/sax/handler.rb', line 9

def parent_handler
  @parent_handler
end

Instance Method Details

#characters(string) ⇒ Object



19
# File 'lib/archimate/file_formats/sax/handler.rb', line 19

def characters(string); end

#completeArray<Event>

Returns array of events to fire for this handler.

Returns:

  • (Array<Event>)

    array of events to fire for this handler



22
23
24
# File 'lib/archimate/file_formats/sax/handler.rb', line 22

def complete
  []
end

#diagramObject



26
27
28
# File 'lib/archimate/file_formats/sax/handler.rb', line 26

def diagram
  parent_handler&.diagram
end

#event(sym, args) ⇒ Object



30
31
32
# File 'lib/archimate/file_formats/sax/handler.rb', line 30

def event(sym, args)
  SaxEvent.new(sym, args, self)
end

#process_text(str) ⇒ Object



48
49
50
# File 'lib/archimate/file_formats/sax/handler.rb', line 48

def process_text(str)
  str&.gsub("&#38;", "&")
end

#property_definitionsObject

Returns the property definitions hash for this SaxDocument



44
45
46
# File 'lib/archimate/file_formats/sax/handler.rb', line 44

def property_definitions
  parent_handler&.property_definitions || []
end

#respond_to_missing?(symbol, _include_all) ⇒ Boolean

Returns:

  • (Boolean)


39
40
41
# File 'lib/archimate/file_formats/sax/handler.rb', line 39

def respond_to_missing?(symbol, _include_all)
  symbol.to_s.start_with?("on_")
end