Class: Lutaml::XMI::Parsers::XML
- Inherits:
-
Object
- Object
- Lutaml::XMI::Parsers::XML
- Defined in:
- lib/lutaml/xmi/parsers/xml.rb
Overview
Class for parsing .xmi schema files into ::Lutaml::Uml::Document
Constant Summary collapse
- LOWER_VALUE_MAPPINGS =
{ "0" => "C", "1" => "M", }.freeze
Instance Attribute Summary collapse
-
#xmi_cache ⇒ Object
readonly
Returns the value of attribute xmi_cache.
-
#xmi_root_model ⇒ Object
readonly
Returns the value of attribute xmi_root_model.
Class Method Summary collapse
- .parse(xml, _options = {}) ⇒ Lutaml::Uml::Document
- .serialize_generalization_by_name(xml, name) ⇒ Hash
- .serialize_xmi(xml, with_gen: false) ⇒ Hash
- .serialize_xmi_to_liquid(xml) ⇒ Liquid::Drop
Instance Method Summary collapse
- #parse(xmi_model) ⇒ Lutaml::Uml::Document
- #serialize_generalization_by_name(xmi_model, name) ⇒ Hash
-
#serialize_xmi(xmi_model, with_gen: false) ⇒ Object
return [Hash].
-
#serialize_xmi_to_liquid(xmi_model) ⇒ Object
return [Liquid::Drop].
- #set_xmi_model(xmi_model) ⇒ Object
Instance Attribute Details
#xmi_cache ⇒ Object (readonly)
Returns the value of attribute xmi_cache.
17 18 19 |
# File 'lib/lutaml/xmi/parsers/xml.rb', line 17 def xmi_cache @xmi_cache end |
#xmi_root_model ⇒ Object (readonly)
Returns the value of attribute xmi_root_model.
17 18 19 |
# File 'lib/lutaml/xmi/parsers/xml.rb', line 17 def xmi_root_model @xmi_root_model end |
Class Method Details
.parse(xml, _options = {}) ⇒ Lutaml::Uml::Document
23 24 25 26 |
# File 'lib/lutaml/xmi/parsers/xml.rb', line 23 def parse(xml, = {}) xmi_model = get_xmi_model(xml) new.parse(xmi_model) end |
.serialize_generalization_by_name(xml, name) ⇒ Hash
46 47 48 49 |
# File 'lib/lutaml/xmi/parsers/xml.rb', line 46 def serialize_generalization_by_name(xml, name) xmi_model = get_xmi_model(xml) new.serialize_generalization_by_name(xmi_model, name) end |
.serialize_xmi(xml, with_gen: false) ⇒ Hash
31 32 33 34 |
# File 'lib/lutaml/xmi/parsers/xml.rb', line 31 def serialize_xmi(xml, with_gen: false) xmi_model = get_xmi_model(xml) new.serialize_xmi(xmi_model, with_gen: with_gen) end |
.serialize_xmi_to_liquid(xml) ⇒ Liquid::Drop
38 39 40 41 |
# File 'lib/lutaml/xmi/parsers/xml.rb', line 38 def serialize_xmi_to_liquid(xml) xmi_model = get_xmi_model(xml) new.serialize_xmi_to_liquid(xmi_model) end |
Instance Method Details
#parse(xmi_model) ⇒ Lutaml::Uml::Document
68 69 70 71 72 73 |
# File 'lib/lutaml/xmi/parsers/xml.rb', line 68 def parse(xmi_model) set_xmi_model(xmi_model) serialized_hash = serialize_xmi(xmi_model) ::Lutaml::Uml::Document.new(serialized_hash) end |
#serialize_generalization_by_name(xmi_model, name) ⇒ Hash
94 95 96 97 98 99 100 101 |
# File 'lib/lutaml/xmi/parsers/xml.rb', line 94 def serialize_generalization_by_name(xmi_model, name) set_xmi_model(xmi_model) model = xmi_model.model klass = find_klass_packaged_element_by_name(name) serialized_hash = build_klass_hash(klass, model, with_gen: true) ::Lutaml::XMI::KlassDrop.new(serialized_hash) end |
#serialize_xmi(xmi_model, with_gen: false) ⇒ Object
return [Hash]
77 78 79 80 |
# File 'lib/lutaml/xmi/parsers/xml.rb', line 77 def serialize_xmi(xmi_model, with_gen: false) set_xmi_model(xmi_model) serialize_to_hash(xmi_model, with_gen: with_gen) end |
#serialize_xmi_to_liquid(xmi_model) ⇒ Object
return [Liquid::Drop]
84 85 86 87 88 89 |
# File 'lib/lutaml/xmi/parsers/xml.rb', line 84 def serialize_xmi_to_liquid(xmi_model) set_xmi_model(xmi_model) serialized_hash = serialize_xmi(xmi_model, with_gen: true) ::Lutaml::XMI::RootDrop.new(serialized_hash) end |
#set_xmi_model(xmi_model) ⇒ Object
61 62 63 64 |
# File 'lib/lutaml/xmi/parsers/xml.rb', line 61 def set_xmi_model(xmi_model) @xmi_cache = {} @xmi_root_model = xmi_model end |