Class: Archimate::FileFormats::Serializer::ModelExchangeFile::ModelExchangeFileWriter
- Inherits:
-
Writer
- Object
- Writer
- Archimate::FileFormats::Serializer::ModelExchangeFile::ModelExchangeFileWriter
- Defined in:
- lib/archimate/file_formats/serializer/model_exchange_file/model_exchange_file_writer.rb
Direct Known Subclasses
Instance Attribute Summary collapse
-
#model ⇒ Object
readonly
Returns the value of attribute model.
Instance Method Summary collapse
-
#identifier(str) ⇒ Object
TODO: Archi uses hex numbers for ids which may not be valid for identifer.
-
#initialize(model) ⇒ ModelExchangeFileWriter
constructor
A new instance of ModelExchangeFileWriter.
- #write(output_io) ⇒ Object
Methods inherited from Writer
Constructor Details
#initialize(model) ⇒ ModelExchangeFileWriter
Returns a new instance of ModelExchangeFileWriter.
11 12 13 |
# File 'lib/archimate/file_formats/serializer/model_exchange_file/model_exchange_file_writer.rb', line 11 def initialize(model) super end |
Instance Attribute Details
#model ⇒ Object (readonly)
Returns the value of attribute model.
9 10 11 |
# File 'lib/archimate/file_formats/serializer/model_exchange_file/model_exchange_file_writer.rb', line 9 def model @model end |
Instance Method Details
#identifier(str) ⇒ Object
TODO: Archi uses hex numbers for ids which may not be valid for identifer. If we are converting from Archi, decorate the IDs here.
24 25 26 27 |
# File 'lib/archimate/file_formats/serializer/model_exchange_file/model_exchange_file_writer.rb', line 24 def identifier(str) return "id-#{str}" if str =~ /^\d/ str end |
#write(output_io) ⇒ Object
15 16 17 18 19 20 |
# File 'lib/archimate/file_formats/serializer/model_exchange_file/model_exchange_file_writer.rb', line 15 def write(output_io) builder = Nokogiri::XML::Builder.new(encoding: 'UTF-8') do |xml| serialize_model(xml, model) end output_io.write(builder.to_xml) end |