Skip to content

Instantly share code, notes, and snippets.

@jasim
Created July 12, 2013 15:32
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 1 You must be signed in to fork a gist
  • Save jasim/5985353 to your computer and use it in GitHub Desktop.
Save jasim/5985353 to your computer and use it in GitHub Desktop.
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