Class: Ea::Sources::Qea::LegendBuilder

Inherits:
Object
  • Object
show all
Defined in:
lib/ea/sources/qea/legend_builder.rb

Overview

Builds an Ea::Model::Legend for a Text element by parsing the sibling t_xref row of name="CustomProperties" on the same GUID. EA encodes legend configuration in the xref's Description field using @PROP=...@ENDPROP; blocks, one per item plus one for the title (LEGEND_STYLE_SETTINGS).

Returns nil when no matching xref exists (the Text element is not a legend — caller should render it as a plain note).

Constant Summary collapse

LEGEND_XREF_NAME =
"CustomProperties"
LEGEND_TYPE_OBJECT_STYLE =
"LEGEND_OBJECTSTYLE"
LEGEND_TYPE_STYLE_SETTINGS =
"LEGEND_STYLE_SETTINGS"
PROP_PATTERN =
/
  @PROP=
  @NAME=(?<name>[^@]*?)@ENDNAME;
  @TYPE=(?<type>[^@]*?)@ENDTYPE;
  @VALU=(?<value>[^@]*?)@ENDVALU;
  (?:@PRMT=(?<prmt>[^@]*?)@ENDPRMT;)?
  @ENDPROP;
/x.freeze

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(database) ⇒ LegendBuilder

Returns a new instance of LegendBuilder.



30
31
32
# File 'lib/ea/sources/qea/legend_builder.rb', line 30

def initialize(database)
  @database = database
end

Instance Attribute Details

#databaseObject (readonly)

Returns the value of attribute database.



28
29
30
# File 'lib/ea/sources/qea/legend_builder.rb', line 28

def database
  @database
end

Instance Method Details

#build_for(ea_guid) ⇒ Object



34
35
36
37
38
39
# File 'lib/ea/sources/qea/legend_builder.rb', line 34

def build_for(ea_guid)
  description = legend_description_for(ea_guid)
  return nil unless description

  build_from_description(description)
end