Class: Txray::Reporters::Live
- Inherits:
-
Object
- Object
- Txray::Reporters::Live
- Defined in:
- lib/txray/reporters/live.rb
Constant Summary collapse
- SPARKS =
%w[▁ ▂ ▃ ▄ ▅ ▆ ▇ █].freeze
- SEVERITY_COLORS =
{ high: 91, medium: 93, low: 96 }.freeze
- HIDE_CURSOR =
"\e[?25l"- SHOW_CURSOR =
"\e[?25h"
Instance Method Summary collapse
- #close(monitor) ⇒ Object
- #draw(monitor) ⇒ Object
-
#initialize(path:, io: $stdout, threshold_ms: 250, color: Reporters.color?(io)) ⇒ Live
constructor
A new instance of Live.
- #open ⇒ Object
Constructor Details
#initialize(path:, io: $stdout, threshold_ms: 250, color: Reporters.color?(io)) ⇒ Live
Returns a new instance of Live.
13 14 15 16 17 18 19 20 |
# File 'lib/txray/reporters/live.rb', line 13 def initialize(path:, io: $stdout, threshold_ms: 250, color: Reporters.color?(io)) @io = io @path = path @threshold_ms = threshold_ms @color = color @width = 100 @height = 40 end |
Instance Method Details
#close(monitor) ⇒ Object
24 25 26 27 28 29 |
# File 'lib/txray/reporters/live.rb', line 24 def close(monitor) @width, @height = @io.print(SHOW_CURSOR) @io.puts summary(monitor) end |
#draw(monitor) ⇒ Object
31 32 33 34 35 36 37 38 39 40 41 |
# File 'lib/txray/reporters/live.rb', line 31 def draw(monitor) @width, @height = @io.print("\e[H\e[2J") title(monitor) meters(monitor) histogram(monitor) feed(monitor) hotspots(monitor) @io.flush end |
#open ⇒ Object
22 |
# File 'lib/txray/reporters/live.rb', line 22 def open = @io.print(HIDE_CURSOR) |