Sha256: 65e3104759672853ff3a1bdbb49a562388b86c5d0225e2536ed8bce294d5ed2b
Contents?: true
Size: 1.11 KB
Versions: 3
Compression:
Stored size: 1.11 KB
Contents
module ShellTastic module Utils # @param [String] str the string the needs to be checked # @return [Boolean] def string_nil_or_blank? str str !~ /[^[:space:]]/ || str.nil? || str.empty? end # @note the `!` it will raise an exception instead of returning a boolean # @param [String] str the string the needs to be checked # @return [ShellTastic::CommandException] def string_nil_or_blank! str # raise if command is empty or nil if str !~ /[^[:space:]]/ || str.nil? || str.empty? raise ShellTastic::CommandException.new("Command is emtpy or nil") end end # like the other methods but allow to set an exception flag # @param [String] str the string the needs to be checked # @param [Boolean] to raise an exception or not. DEFAULT is false # @return [Boolean] # @return [ShellTastic::CommandException] def empty_nil_blank?(str, raize=false) result = (str !~ /[^[:space:]]/ || str.nil? || str.empty?) raise ShellTastic::CommandException.new("Command is emtpy or nil") if result and raize result end end end
Version data entries
3 entries across 3 versions & 1 rubygems
Version | Path |
---|---|
shelltastic-1.0.0 | lib/shelltastic/utils.rb |
shelltastic-0.5.0 | lib/shelltastic/utils.rb |
shelltastic-0.4.0 | lib/shelltastic/utils.rb |