Class: BRS::Stream::Writer
- Includes:
- WriterHelpers
- Defined in:
- lib/brs/stream/writer.rb
Constant Summary
Constants included from Delegates
Instance Attribute Summary
Attributes inherited from Abstract
#external_encoding, #internal_encoding, #io, #pos, #stat, #transcode_options
Instance Method Summary collapse
- #close ⇒ Object
- #close_nonblock(*options) ⇒ Object
- #flush ⇒ Object
- #flush_nonblock(*options) ⇒ Object
-
#initialize(destination_io, options = {}, *args) ⇒ Writer
constructor
A new instance of Writer.
- #rewind ⇒ Object
- #rewind_nonblock(*options) ⇒ Object
-
#write(*objects) ⇒ Object
– synchronous –.
-
#write_nonblock(object, *options) ⇒ Object
– asynchronous –.
Methods included from WriterHelpers
#<<, included, #print, #printf, #putc, #puts
Methods inherited from Abstract
#advise, #closed?, #set_encoding, #to_io
Methods included from Delegates
Constructor Details
#initialize(destination_io, options = {}, *args) ⇒ Writer
Returns a new instance of Writer.
13 14 15 16 17 |
# File 'lib/brs/stream/writer.rb', line 13 def initialize(destination_io, = {}, *args) @options = super destination_io, *args end |
Instance Method Details
#close ⇒ Object
54 55 56 57 58 |
# File 'lib/brs/stream/writer.rb', line 54 def close finish :close super end |
#close_nonblock(*options) ⇒ Object
106 107 108 109 110 111 112 |
# File 'lib/brs/stream/writer.rb', line 106 def close_nonblock(*) return false unless finish_nonblock :close, * method(:close).super_method.call true end |
#flush ⇒ Object
40 41 42 43 44 45 46 |
# File 'lib/brs/stream/writer.rb', line 40 def flush finish :flush @io.flush self end |
#flush_nonblock(*options) ⇒ Object
90 91 92 93 94 95 96 |
# File 'lib/brs/stream/writer.rb', line 90 def flush_nonblock(*) return false unless finish_nonblock :flush, * @io.flush true end |
#rewind ⇒ Object
48 49 50 51 52 |
# File 'lib/brs/stream/writer.rb', line 48 def rewind finish :close super end |
#rewind_nonblock(*options) ⇒ Object
98 99 100 101 102 103 104 |
# File 'lib/brs/stream/writer.rb', line 98 def rewind_nonblock(*) return false unless finish_nonblock :close, * method(:rewind).super_method.call true end |
#write(*objects) ⇒ Object
– synchronous –
25 26 27 28 29 30 31 32 33 34 35 36 37 38 |
# File 'lib/brs/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
– asynchronous –
80 81 82 83 84 85 86 87 88 |
# File 'lib/brs/stream/writer.rb', line 80 def write_nonblock(object, *) return 0 unless write_remaining_buffer_nonblock(*) source = transcode object.to_s bytes_written = raw_nonblock_wrapper :write, source @pos += bytes_written bytes_written end |