Module: IOExtras::AbstractOutputStream

Includes:
FakeIO
Included in:
Zip::ZipOutputStream
Defined in:
lib/zip/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



130
131
132
# File 'lib/zip/ioextras.rb', line 130

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

#printf(aFormatString, *params) ⇒ Object



134
135
136
# File 'lib/zip/ioextras.rb', line 134

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

#putc(anObject) ⇒ Object



138
139
140
141
142
143
144
145
# File 'lib/zip/ioextras.rb', line 138

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



147
148
149
150
151
152
153
154
# File 'lib/zip/ioextras.rb', line 147

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

#write(data) ⇒ Object



124
125
126
127
# File 'lib/zip/ioextras.rb', line 124

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