Class: Hackmac::IOReg
Overview
A class that provides access to IORegistry information through plist parsing
The IOReg class interfaces with macOS’s IORegistry system to retrieve and parse hardware-related information for a specified key. It executes the ioreg command with appropriate flags to fetch XML data, processes this data into a structured hash format, and makes it available for querying through dynamic method calls.
Instance Method Summary collapse
-
#initialize(key:) ⇒ IOReg
constructor
The initialize method sets up an IOReg instance by executing a system command to retrieve hardware registry information for a specific key.
Methods included from Plist
#as_hash, #each, #method_missing, #plist, #to_json
Constructor Details
#initialize(key:) ⇒ IOReg
The initialize method sets up an IOReg instance by executing a system command to retrieve hardware registry information for a specific key.
This method constructs and runs a shell command using the ioreg utility to fetch detailed information about a specified hardware key from the IOService registry. It processes the XML output, extends the resulting hash with deep find capabilities, and stores the largest matching result set in the instance variable.
29 30 31 32 33 |
# File 'lib/hackmac/ioreg.rb', line 29 def initialize(key:) plist(*(%w[ioreg -a -p IOService -r -k ] << key)) @plist.extend Hashie::Extensions::DeepFind @plist = @plist.deep_find_all(key).max_by(&:size) end |
Dynamic Method Handling
This class handles dynamic methods through the method_missing method in the class Hackmac::Plist