Module: Rant::IOExtras::AbstractOutputStream

Includes:
FakeIO
Included in:
Archive::Rubyzip::ZipOutputStream
Defined in:
lib/rant/archive/rubyzip/ioextras.rb

Overview

Implements many of the output convenience methods of IO. relies on <<

Instance Method Summary collapse

Methods included from FakeIO

#kind_of?

Instance Method Details



87
88
89
# File 'lib/rant/archive/rubyzip/ioextras.rb', line 87

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

#printf(aFormatString, *params) ⇒ Object



91
92
93
# File 'lib/rant/archive/rubyzip/ioextras.rb', line 91

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

#putc(anObject) ⇒ Object



95
96
97
98
99
100
101
102
# File 'lib/rant/archive/rubyzip/ioextras.rb', line 95

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



104
105
106
107
108
109
110
111
112
# File 'lib/rant/archive/rubyzip/ioextras.rb', line 104

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



81
82
83
84
# File 'lib/rant/archive/rubyzip/ioextras.rb', line 81

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