Class: A4Tools::FileOverwriteOutput

Inherits:
StandardOutput show all
Defined in:
lib/net_shell/io.rb

Direct Known Subclasses

FileAppendOutput

Instance Attribute Summary

Attributes inherited from StandardOutput

#color

Instance Method Summary collapse

Methods inherited from StandardOutput

#print, #puts

Constructor Details

#initialize(filename) ⇒ FileOverwriteOutput

Returns a new instance of FileOverwriteOutput.



73
74
75
# File 'lib/net_shell/io.rb', line 73

def initialize(filename)
  @filename = filename
end

Instance Method Details

#access_typeObject



77
78
79
# File 'lib/net_shell/io.rb', line 77

def access_type
  "w"
end

#closeObject



88
89
90
# File 'lib/net_shell/io.rb', line 88

def close
  @fd.close
end

#write(s) ⇒ Object



81
82
83
84
85
86
# File 'lib/net_shell/io.rb', line 81

def write(s)
  s = s.unstyle unless @color
  @fd ||= File.open(@filename, access_type)
  @fd.write(s)
  @fd.flush
end