Class: Facter::Util::Windows::Win32Ole
- Inherits:
 - 
      Object
      
        
- Object
 - Facter::Util::Windows::Win32Ole
 
 
- Defined in:
 - lib/facter/util/windows/win32ole.rb
 
Constant Summary collapse
- RPC_C_IMP_LEVEL_IMPERSONATE =
 3
Instance Method Summary collapse
- #exec_query(query) ⇒ Object
 - 
  
    
      #initialize  ⇒ Win32Ole 
    
    
  
  
  
    constructor
  
  
  
  
  
  
  
    
A new instance of Win32Ole.
 - #return_first(query) ⇒ Object
 
Constructor Details
#initialize ⇒ Win32Ole
Returns a new instance of Win32Ole.
      11 12 13 14 15  | 
    
      # File 'lib/facter/util/windows/win32ole.rb', line 11 def initialize locator = WIN32OLE.new('WbemScripting.SWbemLocator') @conn = locator.ConnectServer('.', 'root\\cimv2') @conn.Security_.ImpersonationLevel = RPC_C_IMP_LEVEL_IMPERSONATE end  | 
  
Instance Method Details
#exec_query(query) ⇒ Object
      24 25 26  | 
    
      # File 'lib/facter/util/windows/win32ole.rb', line 24 def exec_query(query) @conn.execquery(query) end  | 
  
#return_first(query) ⇒ Object
      17 18 19 20 21 22  | 
    
      # File 'lib/facter/util/windows/win32ole.rb', line 17 def return_first(query) result = exec_query(query) return result.to_enum.first if result nil end  |