Module: IOExtras::AbstractOutputStream

Includes:
FakeIO
Included in:
Zip::ZipOutputStream
Defined in:
lib/zip/ioextras.rb

Overview

relies on <<

Instance Method Summary collapse

Methods included from FakeIO

#kind_of?

Instance Method Details



79
80
81
# File 'lib/zip/ioextras.rb', line 79

def print(*params)
  self << params.to_s << $\.to_s
end

#printf(aFormatString, *params) ⇒ Object



83
84
85
# File 'lib/zip/ioextras.rb', line 83

def printf(aFormatString, *params)
  self << sprintf(aFormatString, *params)
end

#putc(anObject) ⇒ Object



87
88
89
90
91
92
93
94
# File 'lib/zip/ioextras.rb', line 87

def putc(anObject)
  self << case anObject
   when Fixnum then anObject.chr
   when String then anObject
   else raise TypeError, "putc: Only Fixnum and String supported"
   end
  anObject
end

#puts(*params) ⇒ Object



96
97
98
99
100
101
102
103
104
# File 'lib/zip/ioextras.rb', line 96

def puts(*params)
  params << "\n" if params.empty?
  params.flatten.each {
	|element|
	val = element.to_s
	self << val
	self << "\n" unless val[-1,1] == "\n"
  }
end

#write(data) ⇒ Object



73
74
75
76
# File 'lib/zip/ioextras.rb', line 73

def write(data)
  self << data
  data.to_s.length
end