lib/drawio_dsl/configuration.rb in drawio_dsl-0.11.4 vs lib/drawio_dsl/configuration.rb in drawio_dsl-0.11.5
- old
+ new
@@ -209,26 +209,61 @@
# Configuration for line connections between shapes
class Connector
attr_reader :source_config
- XyConfig = Struct.new(:x, :y, keyword_init: true)
+ class CompassPoint
+ attr_reader :x
+ attr_reader :y
+ def initialize(x, y)
+ @x = x
+ @y = y
+ end
+
+ # should this be start/end
+ def exit_modifiers
+ "exitX=#{x};exitY=#{y};exitDx=0;exitDy=0"
+ end
+
+ def entry_modifiers
+ "entryX=#{x};entryY=#{y};entryDx=0;entryDy=0"
+ end
+ end
+
+ class Arrow
+ attr_reader :image
+ attr_reader :fill
+
+ def initialize(image, fill)
+ @image = image
+ @fill = fill
+ end
+
+ def start_modifiers
+ "startArrow=#{image};startFill=#{fill}"
+ end
+
+ def end_modifiers
+ "endArrow=#{image};endFill=#{fill}"
+ end
+ end
+
def initialize(source_config)
@source_config = source_config
end
def compass_point(key)
- compass_points[key] || XyConfig.new(x: 0, y: 0)
+ compass_points[key] || CompassPoint.new(0, 0)
end
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] = XyConfig.new(x: compass_point['x'], y: compass_point['y'])
+ @compass_points[compass_point['key'].to_sym] = CompassPoint.new(compass_point['x'], compass_point['y'])
end
@compass_points
end
@@ -245,22 +280,34 @@
end
@waypoints
end
+ def random_waypoint_key
+ waypoints.keys.sample
+ end
+
def arrow(key)
- arrows[key] || 'open'
+ arrows[key] || Arrow.new('open', 1)
end
def arrows
return @arrows if defined? @arrows
@arrows = {}
source_config['arrows'].each do |arrow|
- @arrows[arrow['key'].to_sym] = arrow['style']
+ @arrows[arrow['key'].to_sym] = Arrow.new(arrow['image'], arrow['fill'])
end
@arrows
+ end
+
+ def arrow_keys
+ arrows.keys
+ end
+
+ def random_arrow_key
+ arrows.keys.sample
end
def design(key)
designs[key] || ''
end