Class: Toolman::ToolmanS
- Inherits:
-
Object
- Object
- Toolman::ToolmanS
- Defined in:
- lib/toolman.rb
Instance Method Summary collapse
-
#initialize ⇒ ToolmanS
constructor
A new instance of ToolmanS.
- #loading_bar(nowPoint, endPoint) ⇒ Object
- #loading_bar_add ⇒ Object
- #loading_bar_end ⇒ Object
- #puts ⇒ Object
- #say(data) ⇒ Object
Constructor Details
Instance Method Details
#loading_bar(nowPoint, endPoint) ⇒ Object
82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 |
# File 'lib/toolman.rb', line 82 def (nowPoint,endPoint) read, write = IO.pipe @loadBarPid = fork { write.close continue = true sleep_time = 1.0/7.0 index = 0 while(continue) do p = (( (nowPoint*1.0) / endPoint) * 100).floor print "\r" print " \r" print "%5d%s%3s%-3s" % [p,"%","#{@circle[@tempPoint]}",""] @tempPoint = (@tempPoint + 1) % @circleSize if p == 100 print "\r" print " \r" print "%5d%s%3s%-3s" % [p,"%","",""] read.close exit(0) end sleep(sleep_time) s = IO.select([read],[],[],sleep_time) if s result = read.read(1) if result if result.to_i == 1 nowPoint += 1 elsif result.to_i == 0 puts "" puts "Early break..." read.close exit(0) end end index += 1 end end } read.close @write = write # Process.wait(@loadBarPid) # puts "hi" end |
#loading_bar_add ⇒ Object
131 132 133 |
# File 'lib/toolman.rb', line 131 def () @write.write(1) end |
#loading_bar_end ⇒ Object
135 136 137 |
# File 'lib/toolman.rb', line 135 def () @write.write(0) end |
#puts ⇒ Object
71 72 73 |
# File 'lib/toolman.rb', line 71 def puts @colorMechine end |
#say(data) ⇒ Object
76 77 78 79 80 |
# File 'lib/toolman.rb', line 76 def say(data) puts "\n>>>>>>>>>>>>>>>>>Messange>>>>>>>>>>>>>>>>>" puts "#{data}" puts ">>>>>>>>>>>>>>>>>Messange>>>>>>>>>>>>>>>>>\n" end |