Class: Archimate::FileFormats::ModelExchangeFile::XmlLangString
- Inherits:
-
Object
- Object
- Archimate::FileFormats::ModelExchangeFile::XmlLangString
- Defined in:
- lib/archimate/file_formats/model_exchange_file/xml_lang_string.rb
Class Method Summary collapse
Instance Method Summary collapse
-
#initialize(lang_str, tag_name) ⇒ XmlLangString
constructor
A new instance of XmlLangString.
- #serialize(xml) ⇒ Object
Constructor Details
#initialize(lang_str, tag_name) ⇒ XmlLangString
Returns a new instance of XmlLangString.
12 13 14 15 |
# File 'lib/archimate/file_formats/model_exchange_file/xml_lang_string.rb', line 12 def initialize(lang_str, tag_name) @tag_name = tag_name @lang_strs = Array(lang_str) end |
Class Method Details
.parse(node) ⇒ Object
7 8 9 10 |
# File 'lib/archimate/file_formats/model_exchange_file/xml_lang_string.rb', line 7 def self.parse(node) return nil unless node DataModel::LangString.new(text: node.content, lang: node["xml:lang"]) end |
Instance Method Details
#serialize(xml) ⇒ Object
17 18 19 20 21 22 23 24 |
# File 'lib/archimate/file_formats/model_exchange_file/xml_lang_string.rb', line 17 def serialize(xml) return if @lang_strs.empty? @lang_strs.each do |lang_str| attrs = lang_str.lang && !lang_str.lang.empty? ? {"xml:lang" => lang_str.lang} : {} xml.send(@tag_name, attrs) { xml.text text_proc(lang_str) } end end |