Class: LZWS::Stream::Writer
Constant Summary
Constants included
from Delegates
Delegates::DELEGATES
Instance Attribute Summary
Attributes inherited from Abstract
#external_encoding, #internal_encoding, #io, #pos, #stat, #transcode_options
Instance Method Summary
collapse
#<<, included, #print, #printf, #putc, #puts
Methods inherited from Abstract
#advise, #closed?, #set_encoding, #to_io
Methods included from Delegates
included
Constructor Details
#initialize(destination_io, options = {}, *args) ⇒ Writer
13
14
15
16
17
|
# File 'lib/lzws/stream/writer.rb', line 13
def initialize(destination_io, options = {}, *args)
@options = options
super destination_io, *args
end
|
Instance Method Details
#close ⇒ Object
54
55
56
57
58
|
# File 'lib/lzws/stream/writer.rb', line 54
def close
finish :close
super
end
|
#close_nonblock(*options) ⇒ Object
111
112
113
114
115
116
117
|
# File 'lib/lzws/stream/writer.rb', line 111
def close_nonblock(*options)
return false unless finish_nonblock :close, *options
method(:close).super_method.call
true
end
|
#flush ⇒ Object
40
41
42
43
44
45
46
|
# File 'lib/lzws/stream/writer.rb', line 40
def flush
finish :flush
@io.flush
self
end
|
#flush_nonblock(*options) ⇒ Object
95
96
97
98
99
100
101
|
# File 'lib/lzws/stream/writer.rb', line 95
def flush_nonblock(*options)
return false unless finish_nonblock :flush, *options
@io.flush
true
end
|
#rewind ⇒ Object
48
49
50
51
52
|
# File 'lib/lzws/stream/writer.rb', line 48
def rewind
finish :close
super
end
|
#rewind_nonblock(*options) ⇒ Object
103
104
105
106
107
108
109
|
# File 'lib/lzws/stream/writer.rb', line 103
def rewind_nonblock(*options)
return false unless finish_nonblock :close, *options
method(:rewind).super_method.call
true
end
|
#write(*objects) ⇒ Object
25
26
27
28
29
30
31
32
33
34
35
36
37
38
|
# File 'lib/lzws/stream/writer.rb', line 25
def write(*objects)
write_remaining_buffer
bytes_written = 0
objects.each do |object|
source = transcode object.to_s
bytes_written += raw_wrapper :write, source
end
@pos += bytes_written
bytes_written
end
|
#write_nonblock(object, *options) ⇒ Object
IO write nonblock can raise wait writable error. After resolving this error user may provide same content again. It is not possible to revert accepted content after error. So we have to accept content after processing IO write nonblock. It means that first write nonblock won’t call IO write nonblock.
85
86
87
88
89
90
91
92
93
|
# File 'lib/lzws/stream/writer.rb', line 85
def write_nonblock(object, *options)
return 0 unless write_remaining_buffer_nonblock(*options)
source = transcode object.to_s
bytes_written = raw_nonblock_wrapper :write, source
@pos += bytes_written
bytes_written
end
|