Class: Rocx::Properties::ContainerProperty

Inherits:
BaseProperty show all
Includes:
Enumerable, AttributeBuilder
Defined in:
lib/rocx/properties/container_property.rb

Direct Known Subclasses

Columns, Tabs

Constant Summary

Constants included from AttributeBuilder

AttributeBuilder::VALID_THEME_COLORS, AttributeBuilder::VALID_TYPES

Instance Attribute Summary

Attributes inherited from BaseProperty

#value

Class Method Summary collapse

Instance Method Summary collapse

Methods included from AttributeBuilder

#attributes, included

Methods inherited from BaseProperty

#default_name, #default_tag, name, #name, tag, #tag

Constructor Details

#initializeContainerProperty

Returns a new instance of ContainerProperty.



19
20
21
# File 'lib/rocx/properties/container_property.rb', line 19

def initialize
  @children = []
end

Class Method Details

.child_class(*args) ⇒ Object



8
9
10
11
12
13
14
15
16
# File 'lib/rocx/properties/container_property.rb', line 8

def child_class(*args)
  if args.any?
    prop_name = args.first.to_s.capitalize
    child_class_obj = Rocx::Properties.const_get prop_name
    @child_class = Rocx::Properties.const_get prop_name
  end

  @child_class
end

Instance Method Details

#<<(child) ⇒ Object

Raises:

  • (ArgumentError)


23
24
25
26
# File 'lib/rocx/properties/container_property.rb', line 23

def <<(child)
  raise ArgumentError, invalid_child_message unless valid_child?(child)
  children << child
end

#each(*args, &block) ⇒ Object



28
29
30
# File 'lib/rocx/properties/container_property.rb', line 28

def each(*args, &block)
  children.each *args, &block
end

#render?Boolean

Returns:

  • (Boolean)


32
33
34
# File 'lib/rocx/properties/container_property.rb', line 32

def render?
  !children.length.zero?
end

#to_xml(xml) ⇒ Object



36
37
38
39
40
41
42
# File 'lib/rocx/properties/container_property.rb', line 36

def to_xml(xml)
  return unless render?

  xml["w"].public_send(tag, xml_attributes) {
    each { |child| child.to_xml(xml) }
  }
end