Sha256: 0aea00d903f9bb4cbb52bcf7254e1c2d7506ab47db1dc87a3ae7bb063adf26a4

Contents?: true

Size: 906 Bytes

Versions: 10

Compression:

Stored size: 906 Bytes

Contents

# frozen_string_literal: true

module DrawioDsl
  module Schema
    # Provides base configuration for automatic layouts
    class Layout < Node
      attr_accessor :type

      # represents the x coordinate of the top left corner layout area
      # this coordinate is based on the current location of the page
      attr_accessor :anchor_x
      attr_accessor :anchor_y

      def initialize(page, **args)
        @after_init_fired = false

        super(page, **args.merge(classification: :layout_rule))
      end

      def fire_after_init
        return if @after_init_fired

        @after_init_fired = true
        after_init
      end

      def after_init
        @anchor_x ||= page.position_x
        @anchor_y ||= page.position_y
      end

      def to_h
        super.merge(
          type: type,
          anchor_x: anchor_x,
          anchor_y: anchor_y
        )
      end
    end
  end
end

Version data entries

10 entries across 10 versions & 1 rubygems

Version Path
drawio_dsl-0.5.7 lib/drawio_dsl/schema/layouts/layout.rb
drawio_dsl-0.5.6 lib/drawio_dsl/schema/layouts/layout.rb
drawio_dsl-0.5.5 lib/drawio_dsl/schema/layouts/layout.rb
drawio_dsl-0.5.4 lib/drawio_dsl/schema/layouts/layout.rb
drawio_dsl-0.5.3 lib/drawio_dsl/schema/layouts/layout.rb
drawio_dsl-0.5.2 lib/drawio_dsl/schema/layouts/layout.rb
drawio_dsl-0.5.1 lib/drawio_dsl/schema/layouts/layout.rb
drawio_dsl-0.5.0 lib/drawio_dsl/schema/layouts/layout.rb
drawio_dsl-0.4.1 lib/drawio_dsl/schema/layouts/layout.rb
drawio_dsl-0.4.0 lib/drawio_dsl/schema/layouts/layout.rb