Class: Archimate::FileFormats::Sax::ModelExchangeFile::Diagram

Inherits:
Handler
  • Object
show all
Includes:
CaptureDocumentation, CaptureProperties
Defined in:
lib/archimate/file_formats/sax/model_exchange_file/diagram.rb

Instance Attribute Summary

Attributes inherited from Handler

#attrs, #element_type, #name, #parent_handler

Instance Method Summary collapse

Methods included from CaptureProperties

#on_property, #properties

Methods included from CaptureDocumentation

#documentation, #on_preserved_lang_string

Methods inherited from Handler

#characters, #event, #method_missing, #process_text, #property_definitions, #respond_to_missing?

Constructor Details

#initialize(name, attrs, parent_handler) ⇒ Diagram

Returns a new instance of Diagram.



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

def initialize(name, attrs, parent_handler)
  super
  @view_nodes = []
  @connections = []
  @diagram_name = nil
  @diagram = nil
end

Dynamic Method Handling

This class handles dynamic methods through the method_missing method in the class Archimate::FileFormats::Sax::Handler

Instance Method Details

#completeObject



19
20
21
22
23
24
25
26
27
28
29
# File 'lib/archimate/file_formats/sax/model_exchange_file/diagram.rb', line 19

def complete
  diagram.name = @diagram_name
  diagram.documentation = documentation
  diagram.properties = properties
  diagram.nodes = @view_nodes
  diagram.connections = @connections
  [
    event(:on_diagram, diagram),
    event(:on_referenceable, diagram)
  ]
end

#diagramObject



31
32
33
34
35
36
37
38
39
40
# File 'lib/archimate/file_formats/sax/model_exchange_file/diagram.rb', line 31

def diagram
  @diagram ||= DataModel::Diagram.new(
    id: @attrs["identifier"],
    viewpoint_type: @attrs["viewpoint"],
    viewpoint: nil,
    connection_router_type: @attrs["connectionRouterType"],
    type: @attrs["xsi:type"],
    background: @attrs["background"]
  )
end

#on_connection(connection, _source) ⇒ Object



52
53
54
55
# File 'lib/archimate/file_formats/sax/model_exchange_file/diagram.rb', line 52

def on_connection(connection, _source)
  @connections << connection
  false
end

#on_lang_string(name, _source) ⇒ Object



42
43
44
45
# File 'lib/archimate/file_formats/sax/model_exchange_file/diagram.rb', line 42

def on_lang_string(name, _source)
  @diagram_name = name
  false
end

#on_view_node(view_node, source) ⇒ Object



47
48
49
50
# File 'lib/archimate/file_formats/sax/model_exchange_file/diagram.rb', line 47

def on_view_node(view_node, source)
  @view_nodes << view_node if source.parent_handler == self
  false
end