Class: MacSystemMemory

Inherits:
SystemMemory show all
Defined in:
lib/memory.rb

Overview

Memory probe for Mac OS

Constant Summary

Constants inherited from SystemMemory

SystemMemory::UNLIMITED

Instance Attribute Summary

Attributes inherited from SystemMemory

#is_ecc, #size, #speed, #swap_size, #type

Instance Method Summary collapse

Methods inherited from SystemMemory

probe

Constructor Details

#initializeMacSystemMemory

Returns a new instance of MacSystemMemory.



63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
# File 'lib/memory.rb', line 63

def initialize
  `system_profiler SPMemoryDataType > /tmp/memdata.tmp`
  cmd = 'grep ECC /tmp/memdata.tmp | sed -e \'s/.*ECC: //\' | tr -d \'[:space:]\''
  @is_ecc = `#{cmd}` != 'Disabled'

  cmd = "grep Type /tmp/memdata.tmp | uniq | sed -e 's/.*Type: //' | tr -d '[:space:]'"
  @type = `#{cmd}`

  cmd = "grep Speed /tmp/memdata.tmp | uniq | sed -e 's/.*Speed: //' | cut -f1 -d' '"
  @speed = `#{cmd}`.to_i

  cmd = "grep Size /tmp/memdata.tmp | uniq | sed -e 's/.*Size: //' | cut -f1 -d' '"
  slot_size = `#{cmd}`.to_i
  cmd = "grep Size /tmp/memdata.tmp | wc -l | tr -d '[:space:]'"
  slots = `#{cmd}`.to_i

  @size = slots * slot_size
  @swap_size = UNLIMITED
end