Class: Total::Windows
- Inherits:
-
Object
- Object
- Total::Windows
- Defined in:
- lib/total/windows.rb
Overview
Windows specifics.
Instance Method Summary collapse
-
#memory ⇒ Integer
Detects the total physical memory available on Windows systems.
Instance Method Details
#memory ⇒ Integer
This method requires at least one of the Windows utilities (wmic, powershell.exe, or systeminfo) to be available in the system PATH
Detects the total physical memory available on Windows systems.
This method attempts to determine the system’s total RAM using multiple detection strategies to ensure compatibility across different Windows environments and configurations.
Detection methods (tried in order):
-
wmic: Windows Management Instrumentation Command-line tool
-
Most reliable on traditional Windows installations
-
Uses: ‘wmic computersystem get TotalPhysicalMemory /value`
-
-
PowerShell: Windows PowerShell with WMI queries
-
Available on Windows 7+ and MSYS2 environments
-
Uses: ‘Get-WmiObject -Class Win32_ComputerSystem`
-
-
systeminfo: Built-in Windows system information utility
-
Fallback method for restricted environments
-
Parses output to extract memory information in MB/GB format
-
41 42 43 44 |
# File 'lib/total/windows.rb', line 41 def memory try_wmic || try_powershell || try_systeminfo || raise(CantDetect, 'Can\'t detect memory size via wmic, PowerShell, or systeminfo') end |