Class: DrawioDsl::Configuration::Connector

Inherits:
Object
  • Object
show all
Defined in:
lib/drawio_dsl/configuration.rb

Overview

Configuration for line connections between shapes

Defined Under Namespace

Classes: Arrow, CompassPoint

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(source_config) ⇒ Connector

Returns a new instance of Connector.



251
252
253
# File 'lib/drawio_dsl/configuration.rb', line 251

def initialize(source_config)
  @source_config = source_config
end

Instance Attribute Details

#source_configObject (readonly)

Returns the value of attribute source_config.



212
213
214
# File 'lib/drawio_dsl/configuration.rb', line 212

def source_config
  @source_config
end

Instance Method Details

#arrow(key) ⇒ Object



289
290
291
# File 'lib/drawio_dsl/configuration.rb', line 289

def arrow(key)
  arrows[key] || Arrow.new('open', 1)
end

#arrow_keysObject



304
305
306
# File 'lib/drawio_dsl/configuration.rb', line 304

def arrow_keys
  arrows.keys
end

#arrowsObject



293
294
295
296
297
298
299
300
301
302
# File 'lib/drawio_dsl/configuration.rb', line 293

def arrows
  return @arrows if defined? @arrows

  @arrows = {}
  source_config['arrows'].each do |arrow|
    @arrows[arrow['key'].to_sym] = Arrow.new(arrow['image'], arrow['fill'])
  end

  @arrows
end

#compass_point(key) ⇒ Object



255
256
257
# File 'lib/drawio_dsl/configuration.rb', line 255

def compass_point(key)
  compass_points[key] || CompassPoint.new(0, 0)
end

#compass_pointsObject



259
260
261
262
263
264
265
266
267
268
# File 'lib/drawio_dsl/configuration.rb', line 259

def compass_points
  return @compass_points if defined? @compass_points

  @compass_points = {}
  source_config['compass_points'].each do |compass_point|
    @compass_points[compass_point['key'].to_sym] = CompassPoint.new(compass_point['x'], compass_point['y'])
  end

  @compass_points
end

#design(key) ⇒ Object



312
313
314
# File 'lib/drawio_dsl/configuration.rb', line 312

def design(key)
  designs[key] || ''
end

#designsObject



316
317
318
319
320
321
322
323
324
325
# File 'lib/drawio_dsl/configuration.rb', line 316

def designs
  return @designs if defined? @designs

  @designs = {}
  source_config['designs'].each do |design|
    @designs[design['key'].to_sym] = design['style']
  end

  @designs
end

#random_arrow_keyObject



308
309
310
# File 'lib/drawio_dsl/configuration.rb', line 308

def random_arrow_key
  arrows.keys.sample
end

#random_waypoint_keyObject



285
286
287
# File 'lib/drawio_dsl/configuration.rb', line 285

def random_waypoint_key
  waypoints.keys.sample
end

#waypoint(key) ⇒ Object



270
271
272
# File 'lib/drawio_dsl/configuration.rb', line 270

def waypoint(key)
  waypoints[key] || ''
end

#waypointsObject



274
275
276
277
278
279
280
281
282
283
# File 'lib/drawio_dsl/configuration.rb', line 274

def waypoints
  return @waypoints if defined? @waypoints

  @waypoints = {}
  source_config['waypoints'].each do |waypoint|
    @waypoints[waypoint['key'].to_sym] = waypoint['style']
  end

  @waypoints
end