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
- #failed_message(message) ⇒ Object
- #input_message ⇒ Object
- #new_line(num = 0) ⇒ Object
- #show_result ⇒ Object
- #show_status(current_chain, current_object, current_class, chain_count) ⇒ Object
- #welcome_message ⇒ Object
Instance Method Details
#failed_message(message) ⇒ Object
22 23 24 |
# File 'lib/shiritori/view.rb', line 22 def () puts "\e[#{RED}m#{}\e[m" end |
#input_message ⇒ Object
26 27 |
# File 'lib/shiritori/view.rb', line 26 def 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_result ⇒ Object
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_message ⇒ Object
13 14 15 16 17 18 19 20 |
# File 'lib/shiritori/view.rb', line 13 def width = 50 puts "+#{'-' * width}+" puts "|#{' ' * width}|" puts "|#{'Welcome to the Shiritori!'.center(width)}|" puts "|#{' ' * width}|" puts "+#{'-' * width}+" end |