Class: OS::Mac::Diagnostic::Volumes Private
- Defined in:
- extend/os/mac/diagnostic.rb
This class is part of a private API. This class may only be used in the Homebrew/brew repository. Third parties should avoid using this class if possible, as it may be removed or changed without warning.
Instance Method Summary collapse
- #get_mounts(path = nil) ⇒ Array<String> private
- #index_of(path) ⇒ Integer private
- #initialize ⇒ void constructor private
Constructor Details
#initialize ⇒ void
This method is part of a private API. This method may only be used in the Homebrew/brew repository. Third parties should avoid using this method if possible, as it may be removed or changed without warning.
9 10 11 |
# File 'extend/os/mac/diagnostic.rb', line 9 def initialize @volumes = T.let(get_mounts, T::Array[String]) end |
Instance Method Details
#get_mounts(path = nil) ⇒ Array<String>
This method is part of a private API. This method may only be used in the Homebrew/brew repository. Third parties should avoid using this method if possible, as it may be removed or changed without warning.
28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 |
# File 'extend/os/mac/diagnostic.rb', line 28 def get_mounts(path = nil) vols = [] # get the volume of path, if path is nil returns all volumes args = %w[/bin/df -P] args << path.to_s if path Utils.popen_read(*args) do |io| io.each_line do |line| case line.chomp # regex matches: /dev/disk0s2 489562928 440803616 48247312 91% / when /^.+\s+[0-9]+\s+[0-9]+\s+[0-9]+\s+[0-9]{1,3}%\s+(.+)/ vols << Regexp.last_match(1) end end end vols end |
#index_of(path) ⇒ Integer
This method is part of a private API. This method may only be used in the Homebrew/brew repository. Third parties should avoid using this method if possible, as it may be removed or changed without warning.
14 15 16 17 18 19 20 21 22 23 24 25 |
# File 'extend/os/mac/diagnostic.rb', line 14 def index_of(path) vols = get_mounts path # no volume found return -1 if vols.empty? vol_index = @volumes.index(vols[0]) # volume not found in volume list return -1 if vol_index.nil? vol_index end |