Module: IOExtras::AbstractOutputStream
Overview
Implements many of the output convenience methods of IO. relies on <<
Instance Method Summary collapse
- #print(*params) ⇒ Object
- #printf(aFormatString, *params) ⇒ Object
- #putc(anObject) ⇒ Object
- #puts(*params) ⇒ Object
- #write(data) ⇒ Object
Methods included from FakeIO
Instance Method Details
#print(*params) ⇒ Object
120 121 122 123 124 125 |
# File 'lib/zip/ioextras.rb', line 120 def print(*params) if params.size > 0 self << params.join($,.to_s) end self << $\.to_s end |
#printf(aFormatString, *params) ⇒ Object
127 128 129 |
# File 'lib/zip/ioextras.rb', line 127 def printf(aFormatString, *params) self << sprintf(aFormatString, *params) end |
#putc(anObject) ⇒ Object
131 132 133 134 135 136 137 138 |
# File 'lib/zip/ioextras.rb', line 131 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
140 141 142 143 144 145 146 147 148 |
# File 'lib/zip/ioextras.rb', line 140 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
114 115 116 117 |
# File 'lib/zip/ioextras.rb', line 114 def write(data) self << data data.to_s.length end |