Sha256: 2ed1eee6cc8022dd97bfadbef9b655f8f622c6f0739484d5c42dc5b2da72f386
Contents?: true
Size: 1.13 KB
Versions: 1
Compression:
Stored size: 1.13 KB
Contents
# frozen_string_literal: true module Prompts class Form def initialize() @content = nil @prompts = [] @results = [] end def content(&block) @content = Prompts::Content.new yield @content @content end def text(&block) prompt = TextPrompt.new yield(prompt) prepend_form_content_to_prompt(prompt) @prompts << prompt end def select(&block) prompt = SelectPrompt.new yield(prompt) prepend_form_content_to_prompt(prompt) @prompts << prompt end def pause(&block) prompt = PausePrompt.new yield(prompt) prepend_form_content_to_prompt(prompt) @prompts << prompt end def confirm(&block) prompt = ConfirmPrompt.new yield(prompt) prepend_form_content_to_prompt(prompt) @prompts << prompt end def start @prompts.each do |prompt| @results << prompt.ask end @results end private def prepend_form_content_to_prompt(prompt) prompt.prepare_content @content.gap prompt.prepend_content(*@content.slots) end end end
Version data entries
1 entries across 1 versions & 1 rubygems
Version | Path |
---|---|
prompts-0.2.0 | lib/prompts/form.rb |