Class: Fzeet::Windows::OSVERSIONINFOEX
- Inherits:
-
FFI::Struct
- Object
- FFI::Struct
- Fzeet::Windows::OSVERSIONINFOEX
- Includes:
- Comparable
- Defined in:
- lib/fzeet/windows/core/Version.rb
Instance Method Summary collapse
- #<=>(version) ⇒ Object
- #build ⇒ Object
- #get! ⇒ Object
- #hex ⇒ Object
- #major ⇒ Object
- #minor ⇒ Object
- #name ⇒ Object
- #sp ⇒ Object
- #to_s ⇒ Object
Instance Method Details
#<=>(version) ⇒ Object
28 29 30 31 32 33 34 35 36 |
# File 'lib/fzeet/windows/core/Version.rb', line 28 def <=>(version) hex <=> case version when '2000', 2000; 0x0500 when 'xp', :xp; 0x0501 when 'vista', :vista; 0x0600 when '7', 7; 0x0601 else raise ArgumentError end end |
#build ⇒ Object
23 |
# File 'lib/fzeet/windows/core/Version.rb', line 23 def build; self[:dwBuildNumber] end |
#get! ⇒ Object
19 |
# File 'lib/fzeet/windows/core/Version.rb', line 19 def get!; tap { |ovi| ovi[:dwOSVersionInfoSize] = size; Windows.DetonateLastError(0, :GetVersionEx, ovi) } end |
#hex ⇒ Object
26 |
# File 'lib/fzeet/windows/core/Version.rb', line 26 def hex; (major << 8) + minor end |
#major ⇒ Object
21 |
# File 'lib/fzeet/windows/core/Version.rb', line 21 def major; self[:dwMajorVersion] end |
#minor ⇒ Object
22 |
# File 'lib/fzeet/windows/core/Version.rb', line 22 def minor; self[:dwMinorVersion] end |
#name ⇒ Object
40 41 42 43 44 45 46 47 48 |
# File 'lib/fzeet/windows/core/Version.rb', line 40 def name case hex when 0x0500...0x0501; 'Windows 2000' when 0x0501...0x0600; 'Windows XP' when 0x0600...0x0601; 'Windows Vista' when 0x0601...0x0700; 'Windows 7' else 'Unknown' end end |
#sp ⇒ Object
24 |
# File 'lib/fzeet/windows/core/Version.rb', line 24 def sp; self[:wServicePackMajor] end |
#to_s ⇒ Object
50 |
# File 'lib/fzeet/windows/core/Version.rb', line 50 def to_s; "#{major}.#{minor}.#{build} SP#{sp} (#{name})" end |