Class: DrawioDsl::Schema::NodeList

Inherits:
Object
  • Object
show all
Defined in:
lib/drawio_dsl/schema/node_list.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initializeNodeList

Returns a new instance of NodeList.



8
9
10
# File 'lib/drawio_dsl/schema/node_list.rb', line 8

def initialize
  @nodes = []
end

Instance Attribute Details

#nodesObject (readonly)

Returns the value of attribute nodes.



6
7
8
# File 'lib/drawio_dsl/schema/node_list.rb', line 6

def nodes
  @nodes
end

Instance Method Details

#add(parent, node) ⇒ Object



12
13
14
15
# File 'lib/drawio_dsl/schema/node_list.rb', line 12

def add(parent, node)
  node.parent = parent
  @nodes << node
end

#allObject



17
18
19
# File 'lib/drawio_dsl/schema/node_list.rb', line 17

def all
  @nodes
end

#any?Boolean

Returns:

  • (Boolean)


37
38
39
# File 'lib/drawio_dsl/schema/node_list.rb', line 37

def any?
  @nodes.any?
end

#as_xml(xml) ⇒ Object



45
46
47
48
49
# File 'lib/drawio_dsl/schema/node_list.rb', line 45

def as_xml(xml)
  nodes.each do |node|
    node.as_xml(xml) if node.respond_to?(:as_xml)
  end
end

#empty?Boolean

Returns:

  • (Boolean)


33
34
35
# File 'lib/drawio_dsl/schema/node_list.rb', line 33

def empty?
  @nodes.empty?
end

#firstObject



41
42
43
# File 'lib/drawio_dsl/schema/node_list.rb', line 41

def first
  @nodes.first
end

#layoutsObject



25
26
27
# File 'lib/drawio_dsl/schema/node_list.rb', line 25

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

#lengthObject



29
30
31
# File 'lib/drawio_dsl/schema/node_list.rb', line 29

def length
  @nodes.length
end

#shapesObject



21
22
23
# File 'lib/drawio_dsl/schema/node_list.rb', line 21

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

#to_hObject



51
52
53
# File 'lib/drawio_dsl/schema/node_list.rb', line 51

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