Class: Hackmac::Disks

Inherits:
Object
  • Object
show all
Includes:
Plist
Defined in:
lib/hackmac/disks.rb

Overview

A class that provides access to comprehensive disk information by querying macOS’s diskutil command

The Disks class interfaces with the diskutil utility to retrieve detailed information about all disks in the system. It executes system commands to gather plist-formatted data about disk configurations and makes this information available through dynamic method calls for easy access and manipulation.

Examples:

disks = Hackmac::Disks.new
# Provides access to disk information through method calls

Direct Known Subclasses

ContainerDisk

Instance Method Summary collapse

Methods included from Plist

#as_hash, #each, #method_missing, #plist, #to_json

Constructor Details

#initialize(limiter: nil, device: nil) ⇒ Disks

The initialize method sets up a Disks instance by executing a system command to retrieve comprehensive disk information.

This method constructs and runs a shell command using the diskutil utility to fetch detailed information about all disks in the system. It processes the XML output, extends the resulting hash with deep find capabilities, and stores the largest matching result set in the instance variable.

Parameters:

  • limiter (String) (defaults to: nil)

    optional parameter to limit the output of diskutil list

  • device (String) (defaults to: nil)

    optional parameter to specify a particular device to query



62
63
64
# File 'lib/hackmac/disks.rb', line 62

def initialize(limiter: nil, device: nil)
  plist(*(%w[ diskutil list -plist ] + [ limiter, device ].compact))
end

Dynamic Method Handling

This class handles dynamic methods through the method_missing method in the class Hackmac::Plist