Module: RubyWMI
- Extended by:
- RubyWMI
- Included in:
- RubyWMI
- Defined in:
- lib/ruby-wmi.rb,
lib/ruby-wmi/base.rb,
lib/ruby-wmi/errors.rb,
lib/ruby-wmi/version.rb,
lib/ruby-wmi/privilege.rb
Defined Under Namespace
Modules: Privilege Classes: Base, InvalidClass, InvalidNameSpace, InvalidQuery, ReadOnlyError, WMIError
Constant Summary collapse
- VERSION =
'0.4.0'
Instance Method Summary collapse
- #const_missing(name) ⇒ Object
- #instances_of(options) ⇒ Object
-
#namespaces(options = {}) ⇒ Object
(also: #namespaces_of)
Returns an array containing all the WMI namespaces on a sytem.
-
#providers(options = {}) ⇒ Object
(also: #providers_of)
Returns an array containing all the WMI providers on a sytem.
-
#subclasses(options = {}) ⇒ Object
(also: #subclasses_of)
Returns an array containing all the WMI subclasses on a sytem.
Instance Method Details
#const_missing(name) ⇒ Object
81 82 83 |
# File 'lib/ruby-wmi.rb', line 81 def const_missing(name) self.const_set(name, Class.new(self::Base)) end |
#instances_of(options) ⇒ Object
71 72 73 74 75 76 77 |
# File 'lib/ruby-wmi.rb', line 71 def instances_of() Base.set_connection() conn = Base.send(:connection) items = namespaces = conn.send([:method], [:instance]) Base.send(:clear_connection_options) items end |
#namespaces(options = {}) ⇒ Object Also known as: namespaces_of
Returns an array containing all the WMI namespaces on a sytem. Defaults to localhost
WMI.namespaces
For a more human readable version of namespaces when using options:
WMI.namespaces_of(:host => :some_computer)
WMI.namespaces_of(:namespace => "root\\Microsoft")
59 60 61 62 63 64 65 66 67 68 |
# File 'lib/ruby-wmi.rb', line 59 def namespaces( ={}) .merge!(:method => :InstancesOf, :instance => "__NAMESPACE") [:namespace] ||= 'root' instances_of(). map{ |namespace| namespace = "#{[:namespace]}\\#{namespace.name}" ns = namespaces(.merge(:namespace => namespace)) rescue nil [namespace, ns] }.flatten end |
#providers(options = {}) ⇒ Object Also known as: providers_of
Returns an array containing all the WMI providers on a sytem. Defaults to localhost
WMI.providers
For a more human readable version of providers when using options:
WMI.providers_of(:host => :some_computer)
42 43 44 45 46 |
# File 'lib/ruby-wmi.rb', line 42 def providers( ={}) .merge!(:method => :InstancesOf, :instance => "__Win32Provider") instances_of(). map{ |provider| provider.name }.compact end |
#subclasses(options = {}) ⇒ Object Also known as: subclasses_of
Returns an array containing all the WMI subclasses on a sytem. Defaults to localhost
WMI.subclasses
=> ["Win32_PrivilegesStatus", "Win32_TSNetworkAdapterSettingError", ...]
For a more human readable version of subclasses when using options:
WMI.subclasses_of(:host => 'some_computer')
=> ["Win32_PrivilegesStatus", "Win32_TSNetworkAdapterSettingError", ...]
WMI.subclasses_of(
:host => :some_computer,
:namespace => "root\\Microsoft\\SqlServer\\ComputerManagement"
)
27 28 29 30 31 |
# File 'lib/ruby-wmi.rb', line 27 def subclasses( ={}) .merge!(:method => :SubclassesOf) instances_of(). map{ |subclass| subclass.Path_.Class } end |