Class: Output

Inherits:
Object
  • Object
show all
Includes:
Megingiard, Singleton
Defined in:
lib/exogenesis/support/output.rb

Overview

Output is a Singleton. Get the instance via ‘Output.instance`

Constant Summary collapse

WARNING =
'The output of exogenesis is not configurable, the methods for that will be removed in the next version'

Class Method Summary collapse

Instance Method Summary collapse

Constructor Details

#initializeOutput

Returns a new instance of Output.



15
16
17
18
19
20
# File 'lib/exogenesis/support/output.rb', line 15

def initialize
  @canvas = CenteredCanvas.new(STDOUT)
  @success_node = EmojiNode.new(:thumbsup)
  @failure_node = EmojiNode.new(:thumbsdown)
  @skipped_node = EmojiNode.new(:point_right)
end

Class Method Details

.activate_centeringObject



26
27
28
# File 'lib/exogenesis/support/output.rb', line 26

def self.activate_centering
  puts WARNING
end

.activate_decorationObject



30
31
32
# File 'lib/exogenesis/support/output.rb', line 30

def self.activate_decoration
  puts WARNING
end

.activate_utf8Object



34
35
36
# File 'lib/exogenesis/support/output.rb', line 34

def self.activate_utf8
  puts WARNING
end

.fancyObject



22
23
24
# File 'lib/exogenesis/support/output.rb', line 22

def self.fancy
  puts WARNING
end

Instance Method Details

#decorated_header(text, emoji_name) ⇒ Object

Print the text as a decorated header



39
40
41
42
43
# File 'lib/exogenesis/support/output.rb', line 39

def decorated_header(text, emoji_name)
  emoji = EmojiNode.new(emoji_name)
  header = Node.new(emoji, '  ', BoldNode.new(text), ' ', emoji)
  @canvas.draw_centered_row(header)
end

#end_borderObject

Draw the lower bound of a border



83
84
85
# File 'lib/exogenesis/support/output.rb', line 83

def end_border
  puts "\u2514#{"\u2500" * (terminal_width - 2)}\u2518"
end

#failure(info) ⇒ Object

Print the right side with a failure message



59
60
61
62
# File 'lib/exogenesis/support/output.rb', line 59

def failure(info)
  failure = Node.new(' ', info, ' ', @failure_node)
  @canvas.draw_right_column(failure)
end

#info(info) ⇒ Object

Print some arbitrary information on the right



71
72
73
74
# File 'lib/exogenesis/support/output.rb', line 71

def info(info)
  info_node = Node.new(' ', info)
  @canvas.draw_right_column(info_node)
end

#left(text) ⇒ Object

Print the left side of an output



46
47
48
49
50
# File 'lib/exogenesis/support/output.rb', line 46

def left(text)
  text_with_colon = Node.new(text, ':')
  left = ColorNode.new(:white, BoldNode.new(text_with_colon))
  @canvas.draw_left_column(left)
end

#skipped(_info) ⇒ Object

Print the right side with a skipped message



65
66
67
68
# File 'lib/exogenesis/support/output.rb', line 65

def skipped(_info)
  skipped = Node.new(' ', @skipped_node)
  @canvas.draw_right_column(skipped)
end

#start_border(info) ⇒ Object

Draw the upper bound of a border



77
78
79
80
# File 'lib/exogenesis/support/output.rb', line 77

def start_border(info)
  width = (terminal_width - 4 - info.length) / 2
  puts "\u250C#{("\u2500" * width)} #{info} #{("\u2500" * width)}\u2510"
end

#success(_info) ⇒ Object

Print the right side with a success message



53
54
55
56
# File 'lib/exogenesis/support/output.rb', line 53

def success(_info)
  success = Node.new(' ', @success_node)
  @canvas.draw_right_column(success)
end