Sha256: 0a459d395e8d445e7fee4dbf60ccd127d30415e58ef193e4b3232bdc99ebcce3

Contents?: true

Size: 857 Bytes

Versions: 31

Compression:

Stored size: 857 Bytes

Contents

# frozen_string_literal: true

module DrawioDsl
  module Schema
    # Provides base configuration for automatic layouts
    class Layout < Node
      # 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(
          anchor_x: anchor_x,
          anchor_y: anchor_y
        )
      end
    end
  end
end

Version data entries

31 entries across 31 versions & 1 rubygems

Version Path
drawio_dsl-0.8.8 lib/drawio_dsl/schema/layouts/layout.rb
drawio_dsl-0.8.7 lib/drawio_dsl/schema/layouts/layout.rb
drawio_dsl-0.8.6 lib/drawio_dsl/schema/layouts/layout.rb
drawio_dsl-0.8.5 lib/drawio_dsl/schema/layouts/layout.rb
drawio_dsl-0.8.4 lib/drawio_dsl/schema/layouts/layout.rb
drawio_dsl-0.8.3 lib/drawio_dsl/schema/layouts/layout.rb
drawio_dsl-0.8.2 lib/drawio_dsl/schema/layouts/layout.rb
drawio_dsl-0.8.1 lib/drawio_dsl/schema/layouts/layout.rb
drawio_dsl-0.8.0 lib/drawio_dsl/schema/layouts/layout.rb
drawio_dsl-0.7.0 lib/drawio_dsl/schema/layouts/layout.rb
drawio_dsl-0.6.0 lib/drawio_dsl/schema/layouts/layout.rb