Sha256: a807c60b03eae7fc01d06769ff118da5e760eb8e8d9b7cd60dda87bfe8a21d4f

Contents?: true

Size: 573 Bytes

Versions: 7

Compression:

Stored size: 573 Bytes

Contents

# frozen_string_literal: true

module DrawioDsl
  module Schema
    class NodeList
      attr_reader :nodes

      def initialize
        @nodes = []
      end

      def add(node)
        @nodes << node
      end

      def all
        @nodes
      end

      def shapes
        @nodes.select { |node| node.is_a?(DrawioDsl::Schema::Shape) }
      end

      def layouts
        @nodes.select { |node| node.is_a?(DrawioDsl::Schema::Layout) }
      end

      def length
        @nodes.length
      end

      def to_h
        @nodes.map(&:to_h)
      end
    end
  end
end

Version data entries

7 entries across 7 versions & 1 rubygems

Version Path
drawio_dsl-0.5.7 lib/drawio_dsl/schema/node_list.rb
drawio_dsl-0.5.6 lib/drawio_dsl/schema/node_list.rb
drawio_dsl-0.5.5 lib/drawio_dsl/schema/node_list.rb
drawio_dsl-0.5.4 lib/drawio_dsl/schema/node_list.rb
drawio_dsl-0.5.3 lib/drawio_dsl/schema/node_list.rb
drawio_dsl-0.5.2 lib/drawio_dsl/schema/node_list.rb
drawio_dsl-0.5.1 lib/drawio_dsl/schema/node_list.rb