Class: Chef::Util::Powershell::Cmdlet::CmdletStream
- Inherits:
-
Object
- Object
- Chef::Util::Powershell::Cmdlet::CmdletStream
- Defined in:
- lib/chef/util/powershell/cmdlet.rb
Class Method Summary collapse
Instance Method Summary collapse
-
#initialize(name) ⇒ CmdletStream
constructor
A new instance of CmdletStream.
- #path ⇒ Object
- #read ⇒ Object
Constructor Details
#initialize(name) ⇒ CmdletStream
Returns a new instance of CmdletStream.
146 147 148 149 |
# File 'lib/chef/util/powershell/cmdlet.rb', line 146 def initialize(name) @filename = Dir::Tmpname.create(name) {} ObjectSpace.define_finalizer(self, self.class.destroy(@filename)) end |
Class Method Details
.destroy(name) ⇒ Object
163 164 165 |
# File 'lib/chef/util/powershell/cmdlet.rb', line 163 def self.destroy(name) proc { File.delete(name) if File.exists? name } end |
Instance Method Details
#path ⇒ Object
151 152 153 |
# File 'lib/chef/util/powershell/cmdlet.rb', line 151 def path @filename end |
#read ⇒ Object
155 156 157 158 159 160 161 |
# File 'lib/chef/util/powershell/cmdlet.rb', line 155 def read if File.exist? @filename File.open(@filename, "rb:bom|UTF-16LE") do |f| f.read.encode("UTF-8") end end end |