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
53
54
55
56
|
# File 'lib/githug/ui.rb', line 53
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_stream ⇒ Object
Returns the value of attribute in_stream.
6
7
8
|
# File 'lib/githug/ui.rb', line 6
def in_stream
@in_stream
end
|
.out_stream ⇒ Object
Returns the value of attribute out_stream.
6
7
8
|
# File 'lib/githug/ui.rb', line 6
def out_stream
@out_stream
end
|
Class Method Details
.ask(msg) ⇒ Object
34
35
36
|
# File 'lib/githug/ui.rb', line 34
def ask(msg)
request("#{msg} [yn] ") == 'y'
end
|
.colorize(text, color_code) ⇒ Object
38
39
40
41
|
# File 'lib/githug/ui.rb', line 38
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
43
44
45
|
# File 'lib/githug/ui.rb', line 43
def error(text)
colorize(text, "\033[31m")
end
|
.gets ⇒ Object
19
20
21
|
# File 'lib/githug/ui.rb', line 19
def gets
in_stream.gets
end
|
.print(string) ⇒ Object
15
16
17
|
# File 'lib/githug/ui.rb', line 15
def print(string)
out_stream.print(string)
end
|
.puts(string = "") ⇒ Object
11
12
13
|
# File 'lib/githug/ui.rb', line 11
def puts(string = "")
out_stream.puts(string)
end
|
.request(msg) ⇒ Object
29
30
31
32
|
# File 'lib/githug/ui.rb', line 29
def request(msg)
print("#{msg} ")
gets.chomp
end
|
.success(text) ⇒ Object
47
48
49
|
# File 'lib/githug/ui.rb', line 47
def success(text)
colorize(text, "\033[32m")
end
|
.word_box(string, width = 80, char = '*') ⇒ Object
23
24
25
26
27
|
# File 'lib/githug/ui.rb', line 23
def word_box(string,width=80,char='*')
puts char*width
puts "#{char}#{string.center(width-2)}#{char}"
puts char*width
end
|