Class: Hackmac::DiskInfo
Overview
A class that provides detailed information about a specific disk by querying the system’s disk utility.
The DiskInfo class interfaces with macOS’s diskutil command to retrieve comprehensive details about a specified disk.
Instance Attribute Summary collapse
-
#disk ⇒ String
readonly
The disk reader method provides access to the disk identifier that was used when initializing the DiskInfo instance.
Instance Method Summary collapse
-
#initialize(disk:) ⇒ DiskInfo
constructor
The initialize method sets up a DiskInfo instance by retrieving detailed information about a specific disk.
Methods included from Plist
#as_hash, #each, #method_missing, #plist, #to_json
Constructor Details
#initialize(disk:) ⇒ DiskInfo
The initialize method sets up a DiskInfo instance by retrieving detailed information about a specific disk.
This method constructs and executes a system command to fetch comprehensive details about the specified disk using diskutil’s info functionality with plist output format. The resulting plist data is parsed and made available for querying through dynamic method calls.
24 25 26 27 |
# File 'lib/hackmac/disks.rb', line 24 def initialize(disk:) @disk = disk plist(**(%w[ diskutil info -plist ] << disk)) end |
Dynamic Method Handling
This class handles dynamic methods through the method_missing method in the class Hackmac::Plist
Instance Attribute Details
#disk ⇒ String (readonly)
The disk reader method provides access to the disk identifier that was used when initializing the DiskInfo instance.
33 34 35 |
# File 'lib/hackmac/disks.rb', line 33 def disk @disk end |