Class: Chef::Util::Powershell::CmdletResult
- Inherits:
-
Object
- Object
- Chef::Util::Powershell::CmdletResult
- Defined in:
- lib/chef/util/powershell/cmdlet_result.rb
Instance Attribute Summary collapse
-
#output_format ⇒ Object
readonly
Returns the value of attribute output_format.
Instance Method Summary collapse
-
#initialize(status, streams, output_format) ⇒ CmdletResult
constructor
A new instance of CmdletResult.
- #return_value ⇒ Object
- #stderr ⇒ Object
- #stdout ⇒ Object
- #stream(name) ⇒ Object
- #succeeded? ⇒ Boolean
Constructor Details
#initialize(status, streams, output_format) ⇒ CmdletResult
Returns a new instance of CmdletResult.
27 28 29 30 31 |
# File 'lib/chef/util/powershell/cmdlet_result.rb', line 27 def initialize(status, streams, output_format) @status = status @output_format = output_format @streams = streams end |
Instance Attribute Details
#output_format ⇒ Object (readonly)
Returns the value of attribute output_format.
25 26 27 |
# File 'lib/chef/util/powershell/cmdlet_result.rb', line 25 def output_format @output_format end |
Instance Method Details
#return_value ⇒ Object
45 46 47 48 49 50 51 52 53 |
# File 'lib/chef/util/powershell/cmdlet_result.rb', line 45 def return_value if output_format == :object Chef::JSONCompat.parse(stream(:json)) elsif output_format == :json stream(:json) else @status.stdout end end |
#stderr ⇒ Object
37 38 39 |
# File 'lib/chef/util/powershell/cmdlet_result.rb', line 37 def stderr @status.stderr end |
#stdout ⇒ Object
33 34 35 |
# File 'lib/chef/util/powershell/cmdlet_result.rb', line 33 def stdout @status.stdout end |
#stream(name) ⇒ Object
41 42 43 |
# File 'lib/chef/util/powershell/cmdlet_result.rb', line 41 def stream(name) @streams[name].read end |
#succeeded? ⇒ Boolean
55 56 57 |
# File 'lib/chef/util/powershell/cmdlet_result.rb', line 55 def succeeded? @succeeded = @status.status.exitstatus == 0 end |