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.12.4 lib/drawio_dsl/schema/layouts/layout.rb
drawio_dsl-0.12.3 lib/drawio_dsl/schema/layouts/layout.rb
drawio_dsl-0.12.2 lib/drawio_dsl/schema/layouts/layout.rb
drawio_dsl-0.12.1 lib/drawio_dsl/schema/layouts/layout.rb
drawio_dsl-0.12.0 lib/drawio_dsl/schema/layouts/layout.rb
drawio_dsl-0.11.8 lib/drawio_dsl/schema/layouts/layout.rb
drawio_dsl-0.11.7 lib/drawio_dsl/schema/layouts/layout.rb
drawio_dsl-0.11.6 lib/drawio_dsl/schema/layouts/layout.rb
drawio_dsl-0.11.5 lib/drawio_dsl/schema/layouts/layout.rb
drawio_dsl-0.11.4 lib/drawio_dsl/schema/layouts/layout.rb
drawio_dsl-0.11.3 lib/drawio_dsl/schema/layouts/layout.rb
drawio_dsl-0.11.2 lib/drawio_dsl/schema/layouts/layout.rb
drawio_dsl-0.11.1 lib/drawio_dsl/schema/layouts/layout.rb
drawio_dsl-0.11.0 lib/drawio_dsl/schema/layouts/layout.rb
drawio_dsl-0.10.1 lib/drawio_dsl/schema/layouts/layout.rb
drawio_dsl-0.10.0 lib/drawio_dsl/schema/layouts/layout.rb
drawio_dsl-0.9.0 lib/drawio_dsl/schema/layouts/layout.rb
drawio_dsl-0.8.11 lib/drawio_dsl/schema/layouts/layout.rb
drawio_dsl-0.8.10 lib/drawio_dsl/schema/layouts/layout.rb
drawio_dsl-0.8.9 lib/drawio_dsl/schema/layouts/layout.rb