Class: Hackmac::ContainerDisk
Overview
A class that provides access to APFS container disk information by querying macOS’s diskutil command
The ContainerDisk class extends the Disks class to specifically retrieve and process information about Apple File System (APFS) containers
This class initializes by taking a disk identifier and searching for the corresponding Apple_APFS device within the diskutil list output
It then uses the APFS device path to construct a Disks instance, allowing access to detailed APFS container information through dynamic method calls
Instance Method Summary collapse
-
#initialize(disk:, limiter: nil) ⇒ ContainerDisk
constructor
The initialize method sets up a ContainerDisk instance by identifying and initializing with the APFS device associated with a given disk.
Methods included from Plist
#as_hash, #each, #method_missing, #plist, #to_json
Constructor Details
#initialize(disk:, limiter: nil) ⇒ ContainerDisk
The initialize method sets up a ContainerDisk instance by identifying and initializing with the APFS device associated with a given disk.
This method takes a disk identifier and searches for the corresponding Apple_APFS device within the diskutil list output. It extracts the device path and passes it along to the parent Disks class constructor, allowing for further processing of APFS container information.
93 94 95 96 97 98 99 |
# File 'lib/hackmac/disks.rb', line 93 def initialize(disk:, limiter: nil) @disk = disk device = `#{Shellwords.join(%w[ diskutil list ] << disk)}`. lines.grep(/Apple_APFS/).first&.split(/\s+/)&.[](4) super device: device, limiter: limiter end |
Dynamic Method Handling
This class handles dynamic methods through the method_missing method in the class Hackmac::Plist