Class: Memory::Aggregate::Total
- Inherits:
-
Struct
- Object
- Struct
- Memory::Aggregate::Total
- Defined in:
- lib/memory/aggregate.rb
Instance Attribute Summary collapse
-
#count ⇒ Object
Returns the value of attribute count.
-
#memory ⇒ Object
Returns the value of attribute memory.
Instance Method Summary collapse
- #<<(allocation) ⇒ Object
- #as_json ⇒ Object
- #formatted_memory ⇒ Object
-
#initialize ⇒ Total
constructor
A new instance of Total.
- #to_s ⇒ Object
Constructor Details
#initialize ⇒ Total
Returns a new instance of Total.
29 30 31 |
# File 'lib/memory/aggregate.rb', line 29 def initialize super(0, 0) end |
Instance Attribute Details
#count ⇒ Object
Returns the value of attribute count
28 29 30 |
# File 'lib/memory/aggregate.rb', line 28 def count @count end |
#memory ⇒ Object
Returns the value of attribute memory
28 29 30 |
# File 'lib/memory/aggregate.rb', line 28 def memory @memory end |
Instance Method Details
#<<(allocation) ⇒ Object
33 34 35 36 |
# File 'lib/memory/aggregate.rb', line 33 def << allocation self.memory += allocation.size self.count += 1 end |
#as_json ⇒ Object
46 47 48 49 50 51 |
# File 'lib/memory/aggregate.rb', line 46 def as_json { memory: memory, count: count } end |
#formatted_memory ⇒ Object
38 39 40 |
# File 'lib/memory/aggregate.rb', line 38 def formatted_memory self.memory end |
#to_s ⇒ Object
42 43 44 |
# File 'lib/memory/aggregate.rb', line 42 def to_s "(#{Memory.formatted_bytes memory} in #{count} allocations)" end |