Class: Archimate::FileFormats::Writer
- Inherits:
-
Object
- Object
- Archimate::FileFormats::Writer
show all
- Defined in:
- lib/archimate/file_formats/writer.rb
Instance Attribute Summary collapse
Class Method Summary
collapse
Instance Method Summary
collapse
Constructor Details
#initialize(model) ⇒ Writer
Returns a new instance of Writer.
15
16
17
|
# File 'lib/archimate/file_formats/writer.rb', line 15
def initialize(model)
@model = model
end
|
Instance Attribute Details
#model ⇒ Object
Returns the value of attribute model.
8
9
10
|
# File 'lib/archimate/file_formats/writer.rb', line 8
def model
@model
end
|
Class Method Details
.write(model, output_io) ⇒ Object
10
11
12
13
|
# File 'lib/archimate/file_formats/writer.rb', line 10
def self.write(model, output_io)
writer = new(model)
writer.write(output_io)
end
|
Instance Method Details
#remove_nil_values(h) ⇒ Object
50
51
52
53
|
# File 'lib/archimate/file_formats/writer.rb', line 50
def remove_nil_values(h)
h.delete_if { |_k, v| v.nil? }
h
end
|
#serialize(xml, collection) ⇒ Object
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
|
# File 'lib/archimate/file_formats/writer.rb', line 19
def serialize(xml, collection)
Array(collection).each do |item|
case item
when DataModel::Location
serialize_location(xml, item)
when DataModel::Bounds
serialize_bounds(xml, item)
when DataModel::ViewNode
serialize_view_node(xml, item)
when DataModel::Diagram
serialize_diagram(xml, item)
when DataModel::Documentation
ModelExchangeFile::XmlLangString.new(item, :documentation).serialize(xml)
when DataModel::Element
serialize_element(xml, item)
when DataModel::Organization
serialize_organization(xml, item)
when DataModel::Property
serialize_property(xml, item)
when DataModel::Relationship
serialize_relationship(xml, item)
when DataModel::Connection
serialize_connection(xml, item)
when DataModel::Style
serialize_style(xml, item)
else
raise TypeError, "Unexpected item type #{item.class}"
end
end
end
|