Module: ShellTastic::Utils
- Included in:
- IO
- Defined in:
- lib/shelltastic/utils.rb
Instance Method Summary collapse
-
#empty_nil_blank?(str, raize = false) ⇒ Boolean, ShellTastic::CommandException
like the other methods but allow to set an exception flag.
- #string_nil_or_blank!(str) ⇒ ShellTastic::CommandException
- #string_nil_or_blank?(str) ⇒ Boolean
Instance Method Details
#empty_nil_blank?(str, raize = false) ⇒ Boolean, ShellTastic::CommandException
like the other methods but allow to set an exception flag
25 26 27 28 29 |
# File 'lib/shelltastic/utils.rb', line 25 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 |
#string_nil_or_blank!(str) ⇒ ShellTastic::CommandException
Note:
the ‘!` it will raise an exception instead of returning a boolean
13 14 15 16 17 18 |
# File 'lib/shelltastic/utils.rb', line 13 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 |
#string_nil_or_blank?(str) ⇒ Boolean
6 7 8 |
# File 'lib/shelltastic/utils.rb', line 6 def string_nil_or_blank? str str !~ /[^[:space:]]/ || str.nil? || str.empty? end |