Module: TTY::Utils
- Defined in:
- lib/tty/prompt/utils.rb
Constant Summary collapse
- BLANK_REGEX =
/\A[[:space:]]*\z/o.freeze
Class Method Summary collapse
-
.blank?(value) ⇒ Boolean
Check if value is nil or an empty string.
-
.deep_copy(object) ⇒ Object
Deep copy object.
-
.extract_options(args) ⇒ Object
Extract options hash from array argument.
- .extract_options!(args) ⇒ Object
Class Method Details
.blank?(value) ⇒ Boolean
Check if value is nil or an empty string
31 32 33 |
# File 'lib/tty/prompt/utils.rb', line 31 def blank?(value) value.nil? || BLANK_REGEX === value end |
.deep_copy(object) ⇒ Object
Deep copy object
38 39 40 |
# File 'lib/tty/prompt/utils.rb', line 38 def deep_copy(object) Marshal.load(Marshal.dump(object)) end |
.extract_options(args) ⇒ Object
Extract options hash from array argument
14 15 16 17 |
# File 'lib/tty/prompt/utils.rb', line 14 def (args) = args.last .respond_to?(:to_hash) ? .to_hash.dup : {} end |
.extract_options!(args) ⇒ Object
19 20 21 |
# File 'lib/tty/prompt/utils.rb', line 19 def (args) args.last.respond_to?(:to_hash) ? args.pop : {} end |