Module: Zip::IOExtras::AbstractOutputStream
- Includes:
- FakeIO
- Included in:
- OutputStream
- Defined in:
- lib/zip/ioextras/abstract_output_stream.rb
Overview
Implements many of the output convenience methods of IO.
relies on <<
Instance Attribute Summary
Attributes included from FakeIO
#external_encoding, #internal_encoding
Instance Method Summary
collapse
Methods included from FakeIO
#initialize, #kind_of?, #set_encoding
Instance Method Details
#print(*params) ⇒ Object
17
18
19
20
21
22
23
24
25
26
|
# File 'lib/zip/ioextras/abstract_output_stream.rb', line 17
def print(*params)
self << params.join
unless $OUTPUT_RECORD_SEPARATOR.nil? || $OUTPUT_RECORD_SEPARATOR.empty?
self << $OUTPUT_RECORD_SEPARATOR
end
nil
end
|
#printf(a_format_string, *params) ⇒ Object
28
29
30
31
|
# File 'lib/zip/ioextras/abstract_output_stream.rb', line 28
def printf(a_format_string, *params)
self << format(a_format_string, *params)
nil
end
|
#putc(an_object) ⇒ Object
33
34
35
36
37
38
39
40
41
42
43
|
# File 'lib/zip/ioextras/abstract_output_stream.rb', line 33
def putc(an_object)
self << case an_object
when Integer
an_object.chr
when String
an_object
else
raise TypeError, 'putc: Only Integer and String supported'
end
an_object
end
|
#puts(*params) ⇒ Object
45
46
47
48
49
50
51
52
|
# File 'lib/zip/ioextras/abstract_output_stream.rb', line 45
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
12
13
14
15
|
# File 'lib/zip/ioextras/abstract_output_stream.rb', line 12
def write(data)
self << data
data.to_s.bytesize
end
|