Class: Tools::Disclaimer

Inherits:
Object
  • Object
show all
Defined in:
lib/tools/disclaimer.rb

Instance Method Summary collapse

Constructor Details

#initialize(columns: 80, horizontal_character: '=', vertical_character: '|', print_output: true) ⇒ Disclaimer

Returns a new instance of Disclaimer.



5
6
7
8
9
10
# File 'lib/tools/disclaimer.rb', line 5

def initialize(columns: 80, horizontal_character: '=', vertical_character: '|', print_output: true)
  @columns = columns
  @horizontal_character = horizontal_character
  @vertical_character = vertical_character
  @print_output = print_output
end

Instance Method Details

#show(title: nil, texts: []) ⇒ Object

Prints a box containing a title and an explanation of the action that will be performed.

Example:

| | | POSTGRESQL BACKUP GEM | | |

| | | Dolore ipsum sunt amet laborum | | voluptate elit tempor minim | | officia ex amet incididunt. | | |



29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
# File 'lib/tools/disclaimer.rb', line 29

def show(title: nil, texts: [])
  output = ['']

  if title
    output << horizontal_character * columns
    output << empty_line
    output << centralized_text(title)
    output << empty_line
  end

  output << horizontal_character * columns
  output << empty_line

  Array(texts).each do |text|
    paragraphs = break_text_into_paragraphs(text)
    paragraphs.each do |text|
      output << left_aligned_text(text)
    end
  end
  output << empty_line

  output << horizontal_character * columns
  output << ''

  output.each { |line| puts line } if print_output

  output
end