Class: Ea::Export::Xsd::ClassMapping
- Inherits:
-
Object
- Object
- Ea::Export::Xsd::ClassMapping
- Defined in:
- lib/ea/export/xsd/class_mapping.rb
Overview
Loads EA's GMLClassMapping.xml and exposes per-class mapping rules: UML class name → GML element/type/propertyType names.
XML format:
<ClassMapping>
<Class name="FeatureType" element="featureMember"
type="FeaturePropertyType" propertyType="..."
typeContent="complex"/>
</ClassMapping>
Defined Under Namespace
Classes: Mapping
Instance Attribute Summary collapse
-
#mappings ⇒ Object
readonly
Returns the value of attribute mappings.
Class Method Summary collapse
Instance Method Summary collapse
-
#for(class_name) ⇒ Mapping?
Look up a mapping by UML class name.
-
#initialize(mappings = {}) ⇒ ClassMapping
constructor
A new instance of ClassMapping.
Constructor Details
#initialize(mappings = {}) ⇒ ClassMapping
Returns a new instance of ClassMapping.
21 22 23 |
# File 'lib/ea/export/xsd/class_mapping.rb', line 21 def initialize(mappings = {}) @mappings = mappings end |
Instance Attribute Details
#mappings ⇒ Object (readonly)
Returns the value of attribute mappings.
18 19 20 |
# File 'lib/ea/export/xsd/class_mapping.rb', line 18 def mappings @mappings end |
Class Method Details
.from_nokogiri(doc) ⇒ ClassMapping
38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 |
# File 'lib/ea/export/xsd/class_mapping.rb', line 38 def self.from_nokogiri(doc) mappings = {} doc.xpath("//Class").each do |node| name = node["name"] next unless name mappings[name] = Mapping.new( name: name, element: node["element"], type: node["type"], property_type: node["propertyType"], type_content: node["typeContent"] ) end new(mappings) end |
.from_path(path) ⇒ ClassMapping
30 31 32 33 34 |
# File 'lib/ea/export/xsd/class_mapping.rb', line 30 def self.from_path(path) return new if path.nil? || !File.exist?(path) from_nokogiri(Nokogiri::XML(File.read(path))) end |
Instance Method Details
#for(class_name) ⇒ Mapping?
Look up a mapping by UML class name. Returns nil when no explicit mapping exists.
59 60 61 |
# File 'lib/ea/export/xsd/class_mapping.rb', line 59 def for(class_name) mappings[class_name] end |