Sha256: c01e5be7586dda2afd48bb9246f233cafa40ba38816e4c733d413884f66c90bd
Contents?: true
Size: 944 Bytes
Versions: 2
Compression:
Stored size: 944 Bytes
Contents
# frozen_string_literal: true require "tty/prompt" module Interactive # 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) else puts "Invalid parameter" end end end end
Version data entries
2 entries across 2 versions & 1 rubygems
Version | Path |
---|---|
rails-interactive-0.1.1 | lib/interactive/prompt.rb |
rails-interactive-0.1.0 | lib/interactive/prompt.rb |