Class: RgGen::Base::Component
- Inherits:
-
Object
- Object
- RgGen::Base::Component
- Includes:
- SingleForwardable
- Defined in:
- lib/rggen/base/component.rb
Direct Known Subclasses
Instance Attribute Summary collapse
-
#children ⇒ Object
readonly
Returns the value of attribute children.
-
#items ⇒ Object
readonly
Returns the value of attribute items.
-
#level ⇒ Object
readonly
Returns the value of attribute level.
-
#parent ⇒ Object
readonly
Returns the value of attribute parent.
Instance Method Summary collapse
- #add_child(child) ⇒ Object
- #add_item(item) ⇒ Object
-
#initialize(parent) ⇒ Component
constructor
A new instance of Component.
- #need_children? ⇒ Boolean
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
#children ⇒ Object (readonly)
Returns the value of attribute children.
14 15 16 |
# File 'lib/rggen/base/component.rb', line 14 def children @children end |
#items ⇒ Object (readonly)
Returns the value of attribute items.
16 17 18 |
# File 'lib/rggen/base/component.rb', line 16 def items @items end |
#level ⇒ Object (readonly)
Returns the value of attribute level.
15 16 17 |
# File 'lib/rggen/base/component.rb', line 15 def level @level end |
#parent ⇒ Object (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
18 19 20 |
# File 'lib/rggen/base/component.rb', line 18 def need_children? @need_children end |