Class: AdobeCRX::Node
- Inherits:
-
Object
- Object
- AdobeCRX::Node
- Defined in:
- lib/adobe_crx/node.rb
Instance Attribute Summary collapse
-
#children ⇒ Object
Returns the value of attribute children.
-
#path ⇒ Object
Returns the value of attribute path.
-
#size ⇒ Object
Returns the value of attribute size.
Instance Method Summary collapse
- #children_size ⇒ Object
-
#initialize(path) ⇒ Node
constructor
A new instance of Node.
- #total_size ⇒ Object
Constructor Details
#initialize(path) ⇒ Node
Returns a new instance of Node.
4 5 6 7 8 9 |
# File 'lib/adobe_crx/node.rb', line 4 def initialize(path) @path = path @size = 0 @children = [] @cached_size = nil end |
Instance Attribute Details
#children ⇒ Object
Returns the value of attribute children.
2 3 4 |
# File 'lib/adobe_crx/node.rb', line 2 def children @children end |
#path ⇒ Object
Returns the value of attribute path.
2 3 4 |
# File 'lib/adobe_crx/node.rb', line 2 def path @path end |
#size ⇒ Object
Returns the value of attribute size.
2 3 4 |
# File 'lib/adobe_crx/node.rb', line 2 def size @size end |
Instance Method Details
#children_size ⇒ Object
11 12 13 |
# File 'lib/adobe_crx/node.rb', line 11 def children_size @children.inject(0) {|sum, n| sum + n.size } end |
#total_size ⇒ Object
15 16 17 18 19 20 |
# File 'lib/adobe_crx/node.rb', line 15 def total_size if !@cached_size @cached_size = @size + (@children.inject(0) {|sum, n| sum + n.total_size }) end @cached_size end |