Class: DrawioDsl::Configuration::Shape
- Inherits:
-
Object
- Object
- DrawioDsl::Configuration::Shape
show all
- Defined in:
- lib/drawio_dsl/configuration.rb
Defined Under Namespace
Classes: ElementShapeConfig, LineShapeConfig, TextShapeConfig
Instance Attribute Summary collapse
Instance Method Summary
collapse
Constructor Details
#initialize(source_config) ⇒ Shape
Returns a new instance of Shape.
76
77
78
|
# File 'lib/drawio_dsl/configuration.rb', line 76
def initialize(source_config)
@source_config = source_config
end
|
Instance Attribute Details
#source_config ⇒ Object
Returns the value of attribute source_config.
70
71
72
|
# File 'lib/drawio_dsl/configuration.rb', line 70
def source_config
@source_config
end
|
Instance Method Details
#default_element ⇒ Object
104
105
106
107
108
109
110
111
112
113
|
# File 'lib/drawio_dsl/configuration.rb', line 104
def default_element
@default_element ||= ElementShapeConfig.new(
key: :square,
x: 0,
y: 0,
w: 160,
h: 160,
style_modifiers: ''
)
end
|
#default_line ⇒ Object
147
148
149
150
151
152
153
154
155
156
|
# File 'lib/drawio_dsl/configuration.rb', line 147
def default_line
@default_line ||= LineShapeConfig.new(
key: :solid,
x: 0,
y: 0,
w: 50,
h: 50,
style_modifiers: 'edgeStyle=none;exitX=1;exitY=0.5;exitDx=0;exitDy=0;entryX=0;entryY=0.5;entryDx=0;entryDy=0'
)
end
|
#default_text ⇒ Object
190
191
192
193
194
195
196
197
198
199
|
# File 'lib/drawio_dsl/configuration.rb', line 190
def default_text
@default_line ||= TextShapeConfig.new(
key: :p,
x: 0,
y: 0,
w: 100,
h: 50,
style_modifiers: 'text;fontSize=16;fontStyle=1;fillColor=none'
)
end
|
#element(key) ⇒ Object
82
83
84
|
# File 'lib/drawio_dsl/configuration.rb', line 82
def element(key)
elements[key] || default_element
end
|
#element_keys ⇒ Object
115
116
117
|
# File 'lib/drawio_dsl/configuration.rb', line 115
def element_keys
elements.keys
end
|
#elements ⇒ Object
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
|
# File 'lib/drawio_dsl/configuration.rb', line 86
def elements
return @elements if defined? @elements
@elements = {}
source_config['elements'].each do |element|
@elements[element['key'].to_sym] = ElementShapeConfig.new(
key: element['key'].to_sym,
x: element['x'].to_i,
y: element['y'].to_i,
w: element['w'].to_i,
h: element['h'].to_i,
style_modifiers: element['style_modifiers']
)
end
@elements
end
|
#line(key) ⇒ Object
125
126
127
|
# File 'lib/drawio_dsl/configuration.rb', line 125
def line(key)
lines[key] || default_line
end
|
#line_keys ⇒ Object
158
159
160
|
# File 'lib/drawio_dsl/configuration.rb', line 158
def line_keys
lines.keys
end
|
#lines ⇒ Object
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
|
# File 'lib/drawio_dsl/configuration.rb', line 129
def lines
return @lines if defined? @lines
@lines = {}
source_config['lines'].each do |line|
@lines[line['key'].to_sym] = LineShapeConfig.new(
key: line['key'].to_sym,
x: line['x'].to_i,
y: line['y'].to_i,
w: line['w'].to_i,
h: line['h'].to_i,
style_modifiers: line['style_modifiers']
)
end
@lines
end
|
#random_element_key ⇒ Object
119
120
121
|
# File 'lib/drawio_dsl/configuration.rb', line 119
def random_element_key
elements.values.sample.key
end
|
#random_line_key ⇒ Object
162
163
164
|
# File 'lib/drawio_dsl/configuration.rb', line 162
def random_line_key
lines.values.sample.key
end
|
#random_text_key ⇒ Object
205
206
207
|
# File 'lib/drawio_dsl/configuration.rb', line 205
def random_text_key
texts.values.sample.key
end
|
#text(key) ⇒ Object
166
167
168
|
# File 'lib/drawio_dsl/configuration.rb', line 166
def text(key)
texts[key] || default_text
end
|
#text_keys ⇒ Object
201
202
203
|
# File 'lib/drawio_dsl/configuration.rb', line 201
def text_keys
texts.keys
end
|
#texts ⇒ Object
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
|
# File 'lib/drawio_dsl/configuration.rb', line 172
def texts
return @texts if defined? @texts
@texts = {}
source_config['texts'].each do |text|
@texts[text['key'].to_sym] = TextShapeConfig.new(
key: text['key'].to_sym,
x: text['x'].to_i,
y: text['y'].to_i,
w: text['w'].to_i,
h: text['h'].to_i,
style_modifiers: text['style_modifiers']
)
end
@texts
end
|