Class: AdobeCRX::Node

Inherits:
Object
  • Object
show all
Defined in:
lib/adobe_crx/node.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

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

#childrenObject

Returns the value of attribute children.



2
3
4
# File 'lib/adobe_crx/node.rb', line 2

def children
  @children
end

#pathObject

Returns the value of attribute path.



2
3
4
# File 'lib/adobe_crx/node.rb', line 2

def path
  @path
end

#sizeObject

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_sizeObject



11
12
13
# File 'lib/adobe_crx/node.rb', line 11

def children_size
  @children.inject(0) {|sum, n| sum + n.size }
end

#total_sizeObject



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