Module: Bovem::ConsoleMethods::Interactions
- Extended by:
- ActiveSupport::Concern
- Included in:
- Bovem::Console
- Defined in:
- lib/bovem/console.rb
Overview
Methods to interact with the user and other processes.
Defined Under Namespace
Modules: ClassMethods
Instance Method Summary (collapse)
-
- (Object) read(prompt = true, default_value = nil, validator = nil, echo = true)
Reads a string from the console.
-
- (Symbol) task(message = nil, suffix = "\n", indent = true, wrap = false, plain = false, indented_banner = false, full_colored = false, block_indentation = 2, block_indentation_absolute = false)
Executes a block of code in a indentation region and then prints out and ending status message.
Instance Method Details
- (Object) read(prompt = true, default_value = nil, validator = nil, echo = true)
Reads a string from the console.
463 464 465 466 467 468 469 470 471 472 473 474 475 476 477 |
# File 'lib/bovem/console.rb', line 463 def read(prompt = true, default_value = nil, validator = nil, echo = true) prompt = sanitize_prompt(prompt) validator = sanitize_validator(validator) begin catch(:reply) do while true do reply = validate_input_value(read_input_value(prompt, echo, default_value), validator) handle_reply(reply) end end rescue Interrupt default_value end end |
- (Symbol) task(message = nil, suffix = "\n", indent = true, wrap = false, plain = false, indented_banner = false, full_colored = false, block_indentation = 2, block_indentation_absolute = false)
Executes a block of code in a indentation region and then prints out and ending status message.
491 492 493 494 495 496 497 498 499 500 501 502 503 |
# File 'lib/bovem/console.rb', line 491 def task( = nil, suffix = "\n", indent = true, wrap = false, plain = false, = false, full_colored = false, block_indentation = 2, block_indentation_absolute = false) status = nil self.begin(, suffix, indent, wrap, plain, , full_colored) if .present? 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 |