Module: Ea::Transformers::QeaToXmi::Visibility
- Defined in:
- lib/ea/transformers/qea_to_xmi/visibility.rb
Overview
Pure-function mapper from EA's integer scope/containment codes to UML visibility / aggregation wire strings.
EA stores visibility as an integer in t_attribute.scope,
t_operation.scope, t_object.scope. The encoding:
0 → Public
1 → Private
2 → Protected
3 → Package
EA stores aggregation kind in t_connector.sourcecontainment
and t_connector.destcontainment. The encoding:
0 → None (omitted)
1 → Shared (UML aggregation="shared")
2 → Composite (UML aggregation="composite")
Wire-side values are lower-case per the UML XMI schema.
Constant Summary collapse
- SCOPE_MAP =
{ 0 => "public", 1 => "private", 2 => "protected", 3 => "package", }.freeze
- AGGREGATION_MAP =
{ 0 => nil, 1 => "shared", 2 => "composite", }.freeze
Class Method Summary collapse
-
.aggregation_from_containment(raw) ⇒ String?
UML aggregation token, or nil if EA's containment field indicates no aggregation.
-
.boolean_from_flag(raw) ⇒ Boolean?
True / false, or nil if unspecified.
-
.from_scope(raw) ⇒ String?
UML visibility token, or nil if EA's scope field is blank / unrecognised.
Class Method Details
.aggregation_from_containment(raw) ⇒ String?
Returns UML aggregation token, or nil if EA's containment field indicates no aggregation.
54 55 56 57 58 59 |
# File 'lib/ea/transformers/qea_to_xmi/visibility.rb', line 54 def aggregation_from_containment(raw) return nil if raw.nil? || raw.to_s.strip.empty? key = raw.to_i AGGREGATION_MAP[key] end |
.boolean_from_flag(raw) ⇒ Boolean?
True / false, or nil if unspecified.
Returns actual Ruby booleans (not strings) — the xmi gem's
is_* attributes are typed as :boolean.
65 66 67 68 69 |
# File 'lib/ea/transformers/qea_to_xmi/visibility.rb', line 65 def boolean_from_flag(raw) return nil if raw.nil? || raw.to_s.strip.empty? raw.to_s == "1" end |
.from_scope(raw) ⇒ String?
Returns UML visibility token, or nil if EA's scope field is blank / unrecognised.
44 45 46 47 48 49 |
# File 'lib/ea/transformers/qea_to_xmi/visibility.rb', line 44 def from_scope(raw) return nil if raw.nil? || raw.to_s.strip.empty? key = raw.to_i SCOPE_MAP[key] end |