lib/prompts/form.rb in prompts-0.2.1 vs lib/prompts/form.rb in prompts-0.3.0
- old
+ new
@@ -1,12 +1,12 @@
# frozen_string_literal: true
module Prompts
class Form
def self.submit(&block)
- instance = new()
- yield instance if block_given?
+ instance = new
+ yield instance if block
instance.submit
end
def initialize
@content = Prompts::Content.new
@@ -19,31 +19,31 @@
@content
end
def text(label: nil, prompt: "> ", hint: nil, default: nil, required: false, validate: nil, &block)
prompt = TextPrompt.new(label: label, prompt: prompt, hint: hint, default: default, required: required, validate: validate)
- yield(prompt) if block_given?
+ yield(prompt) if block
prepend_form_content_to_prompt(prompt)
@prompts << prompt
end
def select(label: nil, options: nil, prompt: "> ", hint: nil, default: nil, validate: nil, &block)
prompt = SelectPrompt.new(label: label, options: options, prompt: prompt, hint: hint, default: default, validate: validate)
- yield(prompt) if block_given?
+ yield(prompt) if block
prepend_form_content_to_prompt(prompt)
@prompts << prompt
end
def pause(label: nil, prompt: "> ", hint: nil, default: nil, required: false, validate: nil, &block)
prompt = PausePrompt.new(label: label, prompt: prompt, hint: hint, default: default, required: required, validate: validate)
- yield(prompt) if block_given?
+ yield(prompt) if block
prepend_form_content_to_prompt(prompt)
@prompts << prompt
end
def confirm(label: nil, prompt: "> ", hint: nil, default: nil, required: false, validate: nil, &block)
prompt = ConfirmPrompt.new(label: label, prompt: prompt, hint: hint, default: default, required: required, validate: validate)
- yield(prompt) if block_given?
+ yield(prompt) if block
prepend_form_content_to_prompt(prompt)
@prompts << prompt
end
def submit