Class: Memory::Aggregate::Total

Inherits:
Struct
  • Object
show all
Defined in:
lib/memory/aggregate.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initializeTotal

Returns a new instance of Total.



46
47
48
# File 'lib/memory/aggregate.rb', line 46

def initialize
	super(0, 0)
end

Instance Attribute Details

#countObject

Returns the value of attribute count

Returns:

  • (Object)

    the current value of count



45
46
47
# File 'lib/memory/aggregate.rb', line 45

def count
  @count
end

#memoryObject

Returns the value of attribute memory

Returns:

  • (Object)

    the current value of memory



45
46
47
# File 'lib/memory/aggregate.rb', line 45

def memory
  @memory
end

Instance Method Details

#<<(allocation) ⇒ Object



50
51
52
53
# File 'lib/memory/aggregate.rb', line 50

def << allocation
	self.memory += allocation.size
	self.count += 1
end

#formatted_memoryObject



55
56
57
# File 'lib/memory/aggregate.rb', line 55

def formatted_memory
	self.memory
end

#to_sObject



59
60
61
# File 'lib/memory/aggregate.rb', line 59

def to_s
	"(#{Memory.formatted_bytes memory} in #{count} allocations)"
end