Class: YourKarma::CLI::Reporter

Inherits:
Object
  • Object
show all
Defined in:
lib/yourkarma/cli.rb

Constant Summary collapse

DEFAULT_OPTIONS =
{
  io: STDOUT
}

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(options = {}) ⇒ Reporter

Returns a new instance of Reporter.



60
61
62
# File 'lib/yourkarma/cli.rb', line 60

def initialize(options = {})
  self.options = DEFAULT_OPTIONS.merge(options)
end

Instance Attribute Details

#optionsObject

Returns the value of attribute options.



58
59
60
# File 'lib/yourkarma/cli.rb', line 58

def options
  @options
end

Instance Method Details

#report_errorObject



73
74
75
# File 'lib/yourkarma/cli.rb', line 73

def report_error
  write '*' if reported?
end

#report_headerObject



64
65
66
67
# File 'lib/yourkarma/cli.rb', line 64

def report_header
  write "| Connect | Speed | Battery | Charging |\n"
  write "+---------+-------+---------+----------+\n"
end

#report_on(device, benchmark) ⇒ Object



77
78
79
80
81
82
83
84
85
86
87
88
89
# File 'lib/yourkarma/cli.rb', line 77

def report_on(device, benchmark)
  write options[: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)),
    " "
  ].join "|"
  status_code(device, benchmark)
end

#report_progressObject



69
70
71
# File 'lib/yourkarma/cli.rb', line 69

def report_progress
  write '.' if reported?
end

#report_quit(code) ⇒ Object



91
92
93
94
# File 'lib/yourkarma/cli.rb', line 91

def report_quit(code)
  write "\n"
  code || 1
end