module TTY::Utils

Constants

BLANK_REGEX

Public Instance Methods

blank?(value) click to toggle source

Check if value is nil or an empty string

@param [Object] value

the value to check

@return [Boolean]

@api public

# File lib/tty/prompt/utils.rb, line 30
def blank?(value)
  value.nil? || BLANK_REGEX === value
end
deep_copy(object) click to toggle source

Deep copy object

@api public

# File lib/tty/prompt/utils.rb, line 37
def deep_copy(object)
  Marshal.load(Marshal.dump(object))
end
extract_options(args) click to toggle source

Extract options hash from array argument

@param [Array] args

@api public

# File lib/tty/prompt/utils.rb, line 13
def extract_options(args)
  options = args.last
  options.respond_to?(:to_hash) ? options.to_hash.dup : {}
end
extract_options!(args) click to toggle source
# File lib/tty/prompt/utils.rb, line 18
def extract_options!(args)
  args.last.respond_to?(:to_hash) ? args.pop : {}
end