Module: Shiritori::View

Included in:
Main
Defined in:
lib/shiritori/view.rb

Constant Summary collapse

PADDING =
2
RED =

ColorCode

31
GREEN =
32

Instance Method Summary collapse

Instance Method Details

#failed_message(message) ⇒ Object



22
23
24
# File 'lib/shiritori/view.rb', line 22

def failed_message(message)
  puts "\e[#{RED}m#{message}\e[m"
end

#input_messageObject



26
27
# File 'lib/shiritori/view.rb', line 26

def input_message
end

#new_line(num = 0) ⇒ Object



9
10
11
# File 'lib/shiritori/view.rb', line 9

def new_line(num = 0)
  puts "\n" * num
end

#show_resultObject



55
56
# File 'lib/shiritori/view.rb', line 55

def show_result
end

#show_status(current_chain, current_object, current_class, chain_count) ⇒ Object



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
# File 'lib/shiritori/view.rb', line 29

def show_status(current_chain, current_object, current_class, chain_count)
  new_line
  chain = "#{current_chain.join('.')}"
  chain_size = [chain.size + PADDING, 22].max

  puts "+#{'-' * chain_size}+"
  puts "|#{'Current method chain'.center(chain_size)}|"
  puts "+#{'-' * chain_size}+"
  puts "|#{current_chain.join('.').center(chain_size)}|"
  puts "+#{'-' * chain_size}+"

  cls = "#{current_class}"
  obj = "#{current_object.to_ss}"
  cls_size = ["#{current_class}".size, 13].max + PADDING
  cnt_size = 11 + PADDING
  obj_size = ["#{current_object}".size, 14].max + PADDING

  new_line
  puts "+#{'-' * (cls_size)}+#{'-' * cnt_size}+#{'-' * (obj_size)}+"
  puts "|#{'Current Class'.center(cls_size)}|#{'Chain Count'.center(cnt_size)}|#{'Current Object'.center(obj_size)}|"
  puts "+#{'-' * (cls_size)}+#{'-' * cnt_size}+#{'-' * (obj_size)}+"
  puts "|#{cls.center(cls_size)}|#{chain_count.to_s.center(cnt_size)}|#{obj.center(obj_size)}|"
  puts "+#{'-' * (cls_size)}+#{'-' * cnt_size}+#{'-' * (obj_size)}+"
  new_line
end

#welcome_messageObject



13
14
15
16
17
18
19
20
# File 'lib/shiritori/view.rb', line 13

def welcome_message
  width = 50
  puts "+#{'-' * width}+"
  puts "|#{' ' * width}|"
  puts "|#{'Welcome to the Shiritori!'.center(width)}|"
  puts "|#{' ' * width}|"
  puts "+#{'-' * width}+"
end