Class: Mool::Memory
Instance Attribute Summary collapse
-
#mem_used ⇒ Object
Returns the value of attribute mem_used.
-
#unity ⇒ Object
Returns the value of attribute unity.
Instance Method Summary collapse
-
#initialize ⇒ Memory
constructor
A new instance of Memory.
- #to_b ⇒ Object
- #to_gb ⇒ Object
- #to_kb ⇒ Object
- #to_mb ⇒ Object
Methods inherited from Base
Constructor Details
#initialize ⇒ Memory
Returns a new instance of Memory.
6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 |
# File 'lib/mool/memory.rb', line 6 def initialize Mool::Command.meminfo.scan(/(\S+):\s+(\d+)/).each do |meminfo| var = meminfo[0].tr('(', '_').tr(')', '').underscore instance_variable_set( "@#{var}", (meminfo[1].to_f * Mool::PARSE_TYPES[Mool::KBYTES]).round(2) ) class_eval { attr_accessor var.to_sym } end @unity = Mool::BYTES @mem_used = @mem_total - (@mem_free + @cached + @buffers + @swap_cached) end |
Instance Attribute Details
#mem_used ⇒ Object
Returns the value of attribute mem_used.
4 5 6 |
# File 'lib/mool/memory.rb', line 4 def mem_used @mem_used end |
#unity ⇒ Object
Returns the value of attribute unity.
4 5 6 |
# File 'lib/mool/memory.rb', line 4 def unity @unity end |
Instance Method Details
#to_b ⇒ Object
22 23 24 25 26 27 28 |
# File 'lib/mool/memory.rb', line 22 def to_b Mool.parse_to( self, (instance_variable_names - ["@unity"]), Mool::BYTES ) end |
#to_gb ⇒ Object
46 47 48 49 50 51 52 |
# File 'lib/mool/memory.rb', line 46 def to_gb Mool.parse_to( self, (instance_variable_names - ["@unity"]), Mool::GBYTES ) end |
#to_kb ⇒ Object
30 31 32 33 34 35 36 |
# File 'lib/mool/memory.rb', line 30 def to_kb Mool.parse_to( self, (instance_variable_names - ["@unity"]), Mool::KBYTES ) end |
#to_mb ⇒ Object
38 39 40 41 42 43 44 |
# File 'lib/mool/memory.rb', line 38 def to_mb Mool.parse_to( self, (instance_variable_names - ["@unity"]), Mool::MBYTES ) end |