Module: Gitscrub::UI

Included in:
Level
Defined in:
lib/gitscrub/ui.rb

Class Method Summary collapse

Instance Method Summary collapse

Dynamic Method Handling

This class handles dynamic methods through the method_missing method

#method_missing(method, *args, &block) ⇒ Object



67
68
69
70
# File 'lib/gitscrub/ui.rb', line 67

def method_missing(method, *args, &block)
  return UI.send(method, *args) if UI.methods(false).include?(method)
  super
end

Class Method Details

.ask(msg) ⇒ Object



49
50
51
# File 'lib/gitscrub/ui.rb', line 49

def ask(msg)
  request("#{msg} [yn] ") == 'y'
end

.colorize(text, color_code) ⇒ Object



53
54
55
# File 'lib/gitscrub/ui.rb', line 53

def colorize(text, color_code)
  puts "#{color_code}#{text}\033[0m"
end

.error(text) ⇒ Object



57
58
59
# File 'lib/gitscrub/ui.rb', line 57

def error(text)
  colorize(text, "\033[31m")
end

.getsObject



25
26
27
# File 'lib/gitscrub/ui.rb', line 25

def gets
  @@in_stream.gets
end

.in_stream=(in_stream) ⇒ Object



13
14
15
# File 'lib/gitscrub/ui.rb', line 13

def in_stream=(in_stream)
  @@in_stream = in_stream
end

.lineObject



29
30
31
# File 'lib/gitscrub/ui.rb', line 29

def line
  puts("*"*80)
end

.out_stream=(out) ⇒ Object



9
10
11
# File 'lib/gitscrub/ui.rb', line 9

def out_stream=(out)
  @@out_stream = out
end


21
22
23
# File 'lib/gitscrub/ui.rb', line 21

def print(string)
  @@out_stream.print(string)
end

.puts(string = "") ⇒ Object



17
18
19
# File 'lib/gitscrub/ui.rb', line 17

def puts(string = "")
  @@out_stream.puts(string)
end

.request(msg) ⇒ Object



44
45
46
47
# File 'lib/gitscrub/ui.rb', line 44

def request(msg)
  print("#{msg} ")
  gets.chomp
end

.success(text) ⇒ Object



61
62
63
# File 'lib/gitscrub/ui.rb', line 61

def success(text)
  colorize(text, "\033[32m")
end

.word_box(string) ⇒ Object



33
34
35
36
37
38
39
40
41
42
# File 'lib/gitscrub/ui.rb', line 33

def word_box(string)
  space_length = (80/2) - ((string.length/2)+1)
  line
  print "*"
  print " "*space_length
  print string
  print " "*space_length
  puts "*"
  line
end