Module: Githug::UI

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

Class Attribute Summary collapse

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



54
55
56
57
# File 'lib/githug/ui.rb', line 54

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

Class Attribute Details

.in_streamObject

Returns the value of attribute in_stream.



7
8
9
# File 'lib/githug/ui.rb', line 7

def in_stream
  @in_stream
end

.out_streamObject

Returns the value of attribute out_stream.



7
8
9
# File 'lib/githug/ui.rb', line 7

def out_stream
  @out_stream
end

Class Method Details

.ask(msg) ⇒ Object



35
36
37
# File 'lib/githug/ui.rb', line 35

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

.colorize(text, color_code) ⇒ Object



39
40
41
42
# File 'lib/githug/ui.rb', line 39

def colorize(text, color_code)
  return puts text if ENV['OS'] && ENV['OS'].downcase.include?("windows")
  puts "#{color_code}#{text}\033[0m"
end

.error(text) ⇒ Object



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

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

.getsObject



20
21
22
# File 'lib/githug/ui.rb', line 20

def gets
  in_stream.gets
end


16
17
18
# File 'lib/githug/ui.rb', line 16

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

.puts(string = "") ⇒ Object



12
13
14
# File 'lib/githug/ui.rb', line 12

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

.request(msg) ⇒ Object



30
31
32
33
# File 'lib/githug/ui.rb', line 30

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

.success(text) ⇒ Object



48
49
50
# File 'lib/githug/ui.rb', line 48

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

.word_box(string, width = 80, char = '*') ⇒ Object



24
25
26
27
28
# File 'lib/githug/ui.rb', line 24

def word_box(string,width=80,char='*')
  puts char*width
  puts "#{char}#{string.center(width-2)}#{char}"
  puts char*width
end