Class: Fzeet::Windows::OSVERSIONINFOEX

Inherits:
FFI::Struct
  • Object
show all
Includes:
Comparable
Defined in:
lib/fzeet/windows/core/Version.rb

Instance Method Summary collapse

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

#buildObject



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

#hexObject



26
# File 'lib/fzeet/windows/core/Version.rb', line 26

def hex; (major << 8) + minor end

#majorObject



21
# File 'lib/fzeet/windows/core/Version.rb', line 21

def major; self[:dwMajorVersion] end

#minorObject



22
# File 'lib/fzeet/windows/core/Version.rb', line 22

def minor; self[:dwMinorVersion] end

#nameObject



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

#spObject



24
# File 'lib/fzeet/windows/core/Version.rb', line 24

def sp; self[:wServicePackMajor] end

#to_sObject



50
# File 'lib/fzeet/windows/core/Version.rb', line 50

def to_s; "#{major}.#{minor}.#{build} SP#{sp} (#{name})" end