Class: Anywhere::Result
- Inherits:
-
Object
- Object
- Anywhere::Result
- Defined in:
- lib/anywhere/result.rb
Instance Attribute Summary collapse
-
#cmd ⇒ Object
Returns the value of attribute cmd.
-
#exit_status ⇒ Object
Returns the value of attribute exit_status.
-
#stderr ⇒ Object
Returns the value of attribute stderr.
-
#stdout ⇒ Object
Returns the value of attribute stdout.
Instance Method Summary collapse
- #add_stderr(line) ⇒ Object
- #add_stdout(line) ⇒ Object
- #finished!(time = Time.now) ⇒ Object
-
#initialize(cmd) ⇒ Result
constructor
A new instance of Result.
- #inspect ⇒ Object
- #inspect_string(string) ⇒ Object
- #run_time ⇒ Object
- #started!(time = Time.now) ⇒ Object
- #success? ⇒ Boolean
Constructor Details
#initialize(cmd) ⇒ Result
Returns a new instance of Result.
5 6 7 8 9 |
# File 'lib/anywhere/result.rb', line 5 def initialize(cmd) @cmd = cmd @stdout = [] @stderr = [] end |
Instance Attribute Details
#cmd ⇒ Object
Returns the value of attribute cmd.
3 4 5 |
# File 'lib/anywhere/result.rb', line 3 def cmd @cmd end |
#exit_status ⇒ Object
Returns the value of attribute exit_status.
3 4 5 |
# File 'lib/anywhere/result.rb', line 3 def exit_status @exit_status end |
#stderr ⇒ Object
Returns the value of attribute stderr.
3 4 5 |
# File 'lib/anywhere/result.rb', line 3 def stderr @stderr end |
#stdout ⇒ Object
Returns the value of attribute stdout.
3 4 5 |
# File 'lib/anywhere/result.rb', line 3 def stdout @stdout end |
Instance Method Details
#add_stderr(line) ⇒ Object
11 12 13 |
# File 'lib/anywhere/result.rb', line 11 def add_stderr(line) @stderr << line end |
#add_stdout(line) ⇒ Object
15 16 17 |
# File 'lib/anywhere/result.rb', line 15 def add_stdout(line) @stdout << line end |
#finished!(time = Time.now) ⇒ Object
31 32 33 |
# File 'lib/anywhere/result.rb', line 31 def finished!(time = Time.now) @finished = time end |
#inspect ⇒ Object
43 44 45 46 47 48 49 50 |
# File 'lib/anywhere/result.rb', line 43 def inspect parts = ["run_time=#{run_time}"] parts << "cmd=<#{@cmd}>" parts << "stdout=#{inspect_string(@stdout)}" parts << "stderr=#{inspect_string(@stderr)}" parts << "exit_status=#{@exit_status}" "<" + parts.join(", ") + ">" end |
#inspect_string(string) ⇒ Object
52 53 54 55 56 57 58 |
# File 'lib/anywhere/result.rb', line 52 def inspect_string(string) if string.empty? "<empty>" else "<#{string.count} lines, #{string.join(" ").length} chars>" end end |
#run_time ⇒ Object
39 40 41 |
# File 'lib/anywhere/result.rb', line 39 def run_time @finished - @started end |
#started!(time = Time.now) ⇒ Object
27 28 29 |
# File 'lib/anywhere/result.rb', line 27 def started!(time = Time.now) @started = time end |
#success? ⇒ Boolean
35 36 37 |
# File 'lib/anywhere/result.rb', line 35 def success? @exit_status == 0 end |