Module: Bovem::ConsoleMethods::Interactions
Overview
Methods to interact with the user and other processes.
Defined Under Namespace
Modules: ClassMethods
Instance Method Summary collapse
-
#read(prompt: true, default_value: nil, validator: nil, echo: true) ⇒ Object
Reads a string from the console.
-
#task(message = nil, suffix: "\n", indented: true, wrap: false, plain: false, indented_banner: false, full_colored: false, block_indentation: 2, block_indentation_absolute: false) ⇒ Symbol
Executes a block of code in a indentation region and then prints out and ending status message.
Instance Method Details
#read(prompt: true, default_value: nil, validator: nil, echo: true) ⇒ Object
Reads a string from the console.
564 565 566 567 568 569 570 571 572 573 574 575 576 577 578 |
# File 'lib/bovem/console.rb', line 564 def read(prompt: true, default_value: nil, validator: nil, echo: true) prompt = sanitize_prompt(prompt) validator = sanitize_validator(validator) begin catch(:reply) do loop do reply = validate_input_value(read_input_value(prompt, echo, default_value), validator) handle_reply(reply) end end rescue Interrupt default_value end end |
#task(message = nil, suffix: "\n", indented: true, wrap: false, plain: false, indented_banner: false, full_colored: false, block_indentation: 2, block_indentation_absolute: false) ⇒ Symbol
Executes a block of code in a indentation region and then prints out and ending status message.
593 594 595 596 597 598 599 600 601 602 603 604 605 606 607 608 609 610 |
# File 'lib/bovem/console.rb', line 593 def task( = nil, suffix: "\n", indented: true, wrap: false, plain: false, indented_banner: false, full_colored: false, block_indentation: 2, block_indentation_absolute: false ) status = nil if .present? self.begin(, suffix: suffix, indented: indented, wrap: wrap, plain: plain, indented_banner: , full_colored: full_colored) end with_indentation(block_indentation, block_indentation_absolute) do rv = block_given? ? yield.ensure_array : [:ok] # Execute block exit_task(, rv, plain) # Handle task exit status = rv[0] # Return value end status end |