Module: Custodian::Samplers::Utilities
- Included in:
- Sampler
- Defined in:
- lib/custodian/samplers/utilities.rb
Overview
Utility methods for samplers.
Class Method Summary collapse
-
.directory_exists?(directory) ⇒ Boolean
Determine whether the given directory exists.
-
.file_exists?(file) ⇒ Boolean
Determine whether the given file exists.
-
.program_exists?(program) ⇒ Boolean
Determine whether the given program exists.
Class Method Details
.directory_exists?(directory) ⇒ Boolean
Determine whether the given directory exists.
directory - A String describing the path to a directory.
Returns true if the directory exists, or false if it doesn’t.
21 22 23 |
# File 'lib/custodian/samplers/utilities.rb', line 21 def self.directory_exists?(directory) Pathname.new(directory).directory? end |
.file_exists?(file) ⇒ Boolean
Determine whether the given file exists.
file - A String describing the path to a file.
Returns true if the file exists, or false if it doesn’t.
30 31 32 |
# File 'lib/custodian/samplers/utilities.rb', line 30 def self.file_exists?(file) Pathname.new(file).file? end |
.program_exists?(program) ⇒ Boolean
Determine whether the given program exists.
program - A String describing the name of a program.
Returns true if the program exists, or false if it doesn’t.
12 13 14 |
# File 'lib/custodian/samplers/utilities.rb', line 12 def self.program_exists?(program) system "which #{command} > /dev/null 2>&1" end |