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
82 83 84 |
# File 'lib/zip/ioextras.rb', line 82 def print(*params) self << params.to_s << $\.to_s end |
#printf(aFormatString, *params) ⇒ Object
86 87 88 |
# File 'lib/zip/ioextras.rb', line 86 def printf(aFormatString, *params) self << sprintf(aFormatString, *params) end |
#putc(anObject) ⇒ Object
90 91 92 93 94 95 96 97 |
# File 'lib/zip/ioextras.rb', line 90 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
99 100 101 102 103 104 105 106 107 |
# File 'lib/zip/ioextras.rb', line 99 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
76 77 78 79 |
# File 'lib/zip/ioextras.rb', line 76 def write(data) self << data data.to_s.length end |