Class: YourKarma::CLI::Reporter
- Inherits:
-
Object
- Object
- YourKarma::CLI::Reporter
- Defined in:
- lib/yourkarma/cli.rb
Constant Summary collapse
- DEFAULT_OPTIONS =
{ io: STDOUT }
Instance Attribute Summary collapse
-
#options ⇒ Object
Returns the value of attribute options.
Instance Method Summary collapse
-
#initialize(options = {}) ⇒ Reporter
constructor
A new instance of Reporter.
- #report_error ⇒ Object
- #report_header ⇒ Object
- #report_on(device, benchmark) ⇒ Object
- #report_progress ⇒ Object
- #report_quit(code) ⇒ Object
Constructor Details
#initialize(options = {}) ⇒ Reporter
Returns a new instance of Reporter.
60 61 62 |
# File 'lib/yourkarma/cli.rb', line 60 def initialize( = {}) self. = DEFAULT_OPTIONS.merge() end |
Instance Attribute Details
#options ⇒ Object
Returns the value of attribute options.
58 59 60 |
# File 'lib/yourkarma/cli.rb', line 58 def @options end |
Instance Method Details
#report_error ⇒ Object
73 74 75 |
# File 'lib/yourkarma/cli.rb', line 73 def report_error write '*' if reported? end |
#report_header ⇒ Object
64 65 66 67 |
# File 'lib/yourkarma/cli.rb', line 64 def report_header write "| Connect | Speed | Battery | Charging | Bandwidth |\n" write "+---------+-------+---------+----------+-----------+\n" end |
#report_on(device, benchmark) ⇒ Object
77 78 79 80 81 82 83 84 85 86 87 88 89 90 |
# File 'lib/yourkarma/cli.rb', line 77 def report_on(device, benchmark) write [:tail] ? "\n" : "\r" if reported? @reported = true write [ '', pad( 9, connect(device, benchmark)), pad( 7, speed(device, benchmark)), pad( 9, battery(device, benchmark)), pad(10, charging(device, benchmark)), pad(11, bandwidth(device, benchmark)), " " ].join "|" status_code(device, benchmark) end |
#report_progress ⇒ Object
69 70 71 |
# File 'lib/yourkarma/cli.rb', line 69 def report_progress write '.' if reported? end |
#report_quit(code) ⇒ Object
92 93 94 95 |
# File 'lib/yourkarma/cli.rb', line 92 def report_quit(code) write "\n" code || 1 end |