Class: Pong::Hosts
- Inherits:
-
Array
- Object
- Array
- Pong::Hosts
- Defined in:
- lib/pong.rb
Class Method Summary collapse
Instance Method Summary collapse
Class Method Details
Instance Method Details
#run ⇒ Object
179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 |
# File 'lib/pong.rb', line 179 def run start = Time.now each {|host| host.start } while true secs_since_starting = Time.now - start each {|host| host.at_least(secs_since_starting - 1) } system("clear") stats(10) puts stats(60) puts stats sleep(2) end end |
#stats(n = nil) ⇒ Object
170 171 172 173 174 175 176 177 |
# File 'lib/pong.rb', line 170 def stats(n = nil) n = first.pings.size if n.nil? puts "Last #{n} seconds:" puts first.header self.each do |host| puts host.stats(n) end end |