Class: RgGen::Base::Component

Inherits:
Object
  • Object
show all
Includes:
SingleForwardable
Defined in:
lib/rggen/base/component.rb

Direct Known Subclasses

InputBase::Component, OutputBase::Component

Instance Attribute Summary collapse

Instance Method Summary collapse

Methods included from SingleForwardable

#def_object_delegator, #def_object_delegators, #def_single_delegator

Constructor Details

#initialize(parent) ⇒ Component

Returns a new instance of Component.



6
7
8
9
10
11
# File 'lib/rggen/base/component.rb', line 6

def initialize(parent)
  @parent   = parent
  @children = []
  @level    = (parent && parent.level + 1) || 0
  @items    = []
end

Instance Attribute Details

#childrenObject (readonly)

Returns the value of attribute children.



14
15
16
# File 'lib/rggen/base/component.rb', line 14

def children
  @children
end

#itemsObject (readonly)

Returns the value of attribute items.



16
17
18
# File 'lib/rggen/base/component.rb', line 16

def items
  @items
end

#levelObject (readonly)

Returns the value of attribute level.



15
16
17
# File 'lib/rggen/base/component.rb', line 15

def level
  @level
end

#parentObject (readonly)

Returns the value of attribute parent.



13
14
15
# File 'lib/rggen/base/component.rb', line 13

def parent
  @parent
end

Instance Method Details

#add_child(child) ⇒ Object



22
23
24
# File 'lib/rggen/base/component.rb', line 22

def add_child(child)
  @children << child if need_children?
end

#add_item(item) ⇒ Object



26
27
28
# File 'lib/rggen/base/component.rb', line 26

def add_item(item)
  items << item
end

#need_children?Boolean

Returns:

  • (Boolean)


18
19
20
# File 'lib/rggen/base/component.rb', line 18

def need_children?
  @need_children
end