Module: Ea::Sources::Qea::DiagramStyleParser
- Defined in:
- lib/ea/sources/qea/diagram_style_parser.rb
Overview
Parses EA's packed objectstyle / style / styleex
strings into a Hash with typed keys. EA packs visual style
as DUID=...;BCol=...;FCol=...; etc. — semicolon-separated
key=value pairs with non-standard escaping.
Class Method Summary collapse
- .normalize_key(key) ⇒ Object
- .normalize_value(value) ⇒ Object
- .parse(style_string) ⇒ Object
- .parse_pair(pair) ⇒ Object
Class Method Details
.normalize_key(key) ⇒ Object
31 32 33 |
# File 'lib/ea/sources/qea/diagram_style_parser.rb', line 31 def normalize_key(key) key.strip.downcase.to_sym end |
.normalize_value(value) ⇒ Object
35 36 37 38 39 |
# File 'lib/ea/sources/qea/diagram_style_parser.rb', line 35 def normalize_value(value) return "" if value.nil? value.strip end |
.parse(style_string) ⇒ Object
13 14 15 16 17 18 19 20 |
# File 'lib/ea/sources/qea/diagram_style_parser.rb', line 13 def parse(style_string) return {} if style_string.nil? || style_string.empty? style_string.to_s .split(";") .filter_map { |pair| parse_pair(pair) } .to_h end |
.parse_pair(pair) ⇒ Object
22 23 24 25 26 27 28 29 |
# File 'lib/ea/sources/qea/diagram_style_parser.rb', line 22 def parse_pair(pair) return nil unless pair.include?("=") key, value = pair.split("=", 2) return nil if key.nil? || key.empty? [normalize_key(key), normalize_value(value)] end |