Class: Lutaml::Qea::Models::EaDiagramObject
- Inherits:
-
BaseModel
- Object
- Model::Serializable
- BaseModel
- Lutaml::Qea::Models::EaDiagramObject
- Defined in:
- lib/lutaml/qea/models/ea_diagram_object.rb
Overview
Represents a diagram object from the t_diagramobjects table
This model represents the placement of UML elements (classes, packages, etc.) on specific diagrams, including their position and styling.
Class Method Summary collapse
-
.from_db_row(row) ⇒ EaDiagramObject?
Create from database row.
- .primary_key_column ⇒ Object
- .table_name ⇒ Object
Instance Method Summary collapse
-
#bounding_box ⇒ Hash
Get the bounding box of the diagram object.
-
#center_point ⇒ Hash
Get the center point of the diagram object.
-
#parsed_style ⇒ Hash
Parse ObjectStyle string into a hash.
Methods inherited from BaseModel
Class Method Details
.from_db_row(row) ⇒ EaDiagramObject?
Create from database row
35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 |
# File 'lib/lutaml/qea/models/ea_diagram_object.rb', line 35 def self.from_db_row(row) # rubocop:disable Metrics/MethodLength return nil if row.nil? new( diagram_id: row["Diagram_ID"], ea_object_id: row["Object_ID"], recttop: row["RectTop"], rectleft: row["RectLeft"], rectright: row["RectRight"], rectbottom: row["RectBottom"], sequence: row["Sequence"], objectstyle: row["ObjectStyle"], instance_id: row["Instance_ID"], ) end |
.primary_key_column ⇒ Object
23 24 25 |
# File 'lib/lutaml/qea/models/ea_diagram_object.rb', line 23 def self.primary_key_column :instance_id end |
.table_name ⇒ Object
27 28 29 |
# File 'lib/lutaml/qea/models/ea_diagram_object.rb', line 27 def self.table_name "t_diagramobjects" end |
Instance Method Details
#bounding_box ⇒ Hash
Get the bounding box of the diagram object
53 54 55 56 57 58 59 60 61 62 |
# File 'lib/lutaml/qea/models/ea_diagram_object.rb', line 53 def bounding_box { top: recttop, left: rectleft, right: rectright, bottom: rectbottom, width: rectright - rectleft, height: rectbottom - recttop, } end |
#center_point ⇒ Hash
Get the center point of the diagram object
66 67 68 69 70 71 |
# File 'lib/lutaml/qea/models/ea_diagram_object.rb', line 66 def center_point { x: (rectleft + rectright) / 2, y: (recttop + rectbottom) / 2, } end |
#parsed_style ⇒ Hash
Parse ObjectStyle string into a hash
75 76 77 78 79 80 81 82 |
# File 'lib/lutaml/qea/models/ea_diagram_object.rb', line 75 def parsed_style return {} unless objectstyle objectstyle.split(";").each_with_object({}) do |pair, hash| key, value = pair.split("=", 2) hash[key] = value if key && value end end |