Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
class PhysicalStorageVolume
OS_VERSION = RbConfig::CONFIG['host_os']
def initialize(path)
@path = path
@path_exists = File.exists?(path)
end
def raise_error_if_file_doesnt_exist!
raise Errno::ENOENT.new(@path) unless @path_exists
end
def uuid
raise_error_if_file_doesnt_exist!
@uuid ||= `diskutil info #{disk_name} | grep UUID`.split.last
end
def volume_label
raise_error_if_file_doesnt_exist!
unless @volume_label
vname = 'Volume Name:'
vname_line = `diskutil info #{disk_name} | grep '#{vname}'`
@volume_label = vname_line.sub(vname, '').strip
end
@volume_label
end
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment