Class: Whereis
- Inherits:
-
Object
- Object
- Whereis
- Defined in:
- lib/unix/whereis.rb
Overview
UNIX whereis
command frontend.
Constant Summary collapse
- TYPES =
Target types to arguments conversion table.
{ :binary => :b, :manual => :m, :source => :s, :unusual => :u, }
- PATHS =
Target type path settings to arguments conversion table.
{ :binary => :B, :manual => :M, :source => :S, }
Class Method Summary collapse
-
.available?(name, type = :binary) ⇒ Boolean
Indicates, file of the target type is available.
-
.binary?(name, options = nil) ⇒ Array
Checks where is some binary file.
-
.file?(name, options = [ ]) ⇒ Array
Checks where is some file.
-
.manual?(name, options = nil) ⇒ Array
Checks where is some manual page file.
-
.source?(name, options = nil) ⇒ Array
Checks where is some source file.
Class Method Details
.available?(name, type = :binary) ⇒ Boolean
Indicates, file of the target type is available.
167 168 169 |
# File 'lib/unix/whereis.rb', line 167 def self.available?(name, type = :binary) self.file?(name, type).length > 0 end |
.binary?(name, options = nil) ⇒ Array .binary?(name, options = { }) ⇒ Array
Checks where is some binary file. By default uses default whereis options.
111 112 113 |
# File 'lib/unix/whereis.rb', line 111 def self.binary?(name, = nil) __get(name, :binary, ) end |
.file?(name, options = nil) ⇒ Array .file?(name, options = [ ]) ⇒ Array .file?(name, options = { }) ⇒ Array
Checks where is some file. By default uses default whereis options.
71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 |
# File 'lib/unix/whereis.rb', line 71 def self.file?(name, = [ ]) # Parses arguments cmd = CommandBuilder::new(:whereis) if .symbol? __add_type(cmd, ) elsif .array? .each { |i| __add_type(cmd, i) } elsif .hash? .each_pair { |n, v| __add_path(cmd, n, v) } end cmd << name.to_s # Parses output output = cmd.execute[(name.to_s.length + 2)..-1] return output.split(" ") end |
.manual?(name, options = nil) ⇒ Array .manual?(name, options = { }) ⇒ Array
Checks where is some manual page file. By default uses default whereis options.
135 136 137 |
# File 'lib/unix/whereis.rb', line 135 def self.manual?(name, = nil) __get(name, :manual, ) end |
.source?(name, options = nil) ⇒ Array .source?(name, options = { }) ⇒ Array
Checks where is some source file. By default uses default whereis options.
159 160 161 |
# File 'lib/unix/whereis.rb', line 159 def self.source?(name, = nil) __get(name, :source, ) end |