Sha256: 67708b473ecbdea5b5c9c3a73be3cd144ef491504e93e4797cf30dae7670f504
Contents?: true
Size: 1020 Bytes
Versions: 7
Compression:
Stored size: 1020 Bytes
Contents
# frozen_string_literal: true require "tty/prompt" module RailsInteractive # Prompt class for commands class Prompt # Create a new instance # # @param msg [String] the message to display # @param type [String] the type of prompt # @param options [Array] the options to display # @param required [Boolean] whether the prompt value is required # # @return [Interactive::Prompt] the new instance def initialize(msg, type, options = nil, required: false) @msg = msg @type = type @options = options @required = required @prompt = TTY::Prompt.new end # Perform the prompt # # @return [String] the value of the prompt def perform case @type when "ask" @prompt.ask(@msg, required: @required) when "select" @prompt.select(@msg, @options, required: @required) when "multi_select" @prompt.multi_select(@msg, @options) else puts "Invalid parameter" end end end end
Version data entries
7 entries across 7 versions & 1 rubygems