Module: Sinatra::Streaming::Stream
Relationships & Source Files | |
Defined in: | sinatra-contrib/lib/sinatra/streaming.rb |
Class Method Summary
Instance Attribute Summary
- #app rw
-
#closed?
rw
Alias for #closed.
- #closed_read? ⇒ Boolean readonly
- #closed_write? ⇒ Boolean readonly
-
#isatty
readonly
Alias for #tty?.
- #lineno rw
- #pos (also: #tell) rw
-
#tell
readonly
Alias for #pos.
- #transformer rw
- #tty? ⇒ Boolean (also: #isatty) readonly
Instance Method Summary
- #<<(data)
-
#bytes
Alias for #not_open_for_reading.
-
#chars
Alias for #enum_not_open_for_reading.
- #close_read
- #closed (also: #closed?) rw
- #dummy (also: #flush, #fsync, #internal_encoding, #pid)
- #each
-
#each_byte
Alias for #enum_not_open_for_reading.
-
#each_char
Alias for #enum_not_open_for_reading.
-
#each_line
Alias for #enum_not_open_for_reading.
- #enum_not_open_for_reading (also: #chars, #each_line, #each_byte, #each_char, #lines)
-
#eof
Alias for #not_open_for_reading.
-
#eof?
Alias for #not_open_for_reading.
- #external_encoding
-
#flush
Alias for #dummy.
-
#fsync
Alias for #dummy.
-
#getbyte
Alias for #not_open_for_reading.
-
#getc
Alias for #not_open_for_reading.
-
#gets
Alias for #not_open_for_reading.
-
#internal_encoding
Alias for #dummy.
-
#lines
Alias for #enum_not_open_for_reading.
- #map(&block)
- #map!(&block)
-
#pid
Alias for #dummy.
- #print(*args)
- #printf(format, *args)
- #putc(c)
- #puts(*args)
-
#read
Alias for #not_open_for_reading.
-
#read_nonblock
Alias for #not_open_for_reading.
-
#readbyte
Alias for #not_open_for_reading.
-
#readchar
Alias for #not_open_for_reading.
-
#readline
Alias for #not_open_for_reading.
-
#readlines
Alias for #not_open_for_reading.
-
#readpartial
Alias for #not_open_for_reading.
- #rewind
- #seek (also: #sysseek)
- #settings
- #sync
-
#sysread
Alias for #not_open_for_reading.
-
#sysseek
Alias for #seek.
-
#syswrite(data)
Alias for #write.
-
#ungetbyte
Alias for #not_open_for_reading.
-
#ungetc
Alias for #not_open_for_reading.
- #write(data) (also: #syswrite, #write_nonblock)
-
#write_nonblock(data)
Alias for #write.
- #not_open_for_reading (also: #bytes, #eof?, #eof, #getbyte, #getc, #gets, #read, #read_nonblock, #readbyte, #readchar, #readline, #readlines, #readpartial, #sysread, #ungetbyte, #ungetc) private
Class Method Details
.extended(obj)
[ GitHub ]Instance Attribute Details
#app (rw)
[ GitHub ]# File 'sinatra-contrib/lib/sinatra/streaming.rb', line 88
attr_accessor :app, :lineno, :pos, :transformer, :closed
#closed? (rw)
Alias for #closed.
# File 'sinatra-contrib/lib/sinatra/streaming.rb', line 90
alias closed? closed
#closed_read? ⇒ Boolean
(readonly)
[ GitHub ]
# File 'sinatra-contrib/lib/sinatra/streaming.rb', line 164
def closed_read? true end
#closed_write? ⇒ Boolean
(readonly)
[ GitHub ]
# File 'sinatra-contrib/lib/sinatra/streaming.rb', line 168
def closed_write? closed? end
#isatty (readonly)
Alias for #tty?.
# File 'sinatra-contrib/lib/sinatra/streaming.rb', line 241
alias isatty tty?
#lineno (rw)
[ GitHub ]# File 'sinatra-contrib/lib/sinatra/streaming.rb', line 88
attr_accessor :app, :lineno, :pos, :transformer, :closed
#pos (rw) Also known as: #tell
[ GitHub ]# File 'sinatra-contrib/lib/sinatra/streaming.rb', line 88
attr_accessor :app, :lineno, :pos, :transformer, :closed
#tell (readonly)
Alias for #pos.
# File 'sinatra-contrib/lib/sinatra/streaming.rb', line 89
alias tell pos
#transformer (rw)
[ GitHub ]
#tty? ⇒ Boolean
(readonly)
Also known as: #isatty
[ GitHub ]
# File 'sinatra-contrib/lib/sinatra/streaming.rb', line 237
def tty? false end
Instance Method Details
#<<(data)
# File 'sinatra-contrib/lib/sinatra/streaming.rb', line 100
def <<(data) raise IOError, 'not opened for writing' if closed? @transformer ||= nil data = data.to_s data = @transformer[data] if @transformer @pos += data.bytesize super(data) end
#bytes
Alias for #not_open_for_reading.
# File 'sinatra-contrib/lib/sinatra/streaming.rb', line 190
alias bytes not_open_for_reading
#chars
Alias for #enum_not_open_for_reading.
# File 'sinatra-contrib/lib/sinatra/streaming.rb', line 213
alias chars enum_not_open_for_reading
#close_read
# File 'sinatra-contrib/lib/sinatra/streaming.rb', line 160
def close_read raise IOError, 'closing non-duplex IO for reading' end
#closed (rw) Also known as: #closed?
[ GitHub ]# File 'sinatra-contrib/lib/sinatra/streaming.rb', line 88
attr_accessor :app, :lineno, :pos, :transformer, :closed
#dummy Also known as: #flush, #fsync, #internal_encoding, #pid
[ GitHub ]# File 'sinatra-contrib/lib/sinatra/streaming.rb', line 220
def dummy(*) end
#each
[ GitHub ]# File 'sinatra-contrib/lib/sinatra/streaming.rb', line 110
def each # that way body.each.map { ... } works return self unless block_given? super end
#each_byte
Alias for #enum_not_open_for_reading.
# File 'sinatra-contrib/lib/sinatra/streaming.rb', line 215
alias each_byte enum_not_open_for_reading
#each_char
Alias for #enum_not_open_for_reading.
# File 'sinatra-contrib/lib/sinatra/streaming.rb', line 216
alias each_char enum_not_open_for_reading
#each_line
Alias for #enum_not_open_for_reading.
# File 'sinatra-contrib/lib/sinatra/streaming.rb', line 214
alias each_line enum_not_open_for_reading
#enum_not_open_for_reading Also known as: #chars, #each_line, #each_byte, #each_char, #lines
[ GitHub ]# File 'sinatra-contrib/lib/sinatra/streaming.rb', line 208
def enum_not_open_for_reading(*) not_open_for_reading if block_given? enum_for(:not_open_for_reading) end
#eof
Alias for #not_open_for_reading.
# File 'sinatra-contrib/lib/sinatra/streaming.rb', line 192
alias eof not_open_for_reading
#eof?
Alias for #not_open_for_reading.
# File 'sinatra-contrib/lib/sinatra/streaming.rb', line 191
alias eof? not_open_for_reading
#external_encoding
[ GitHub ]#flush
Alias for #dummy.
# File 'sinatra-contrib/lib/sinatra/streaming.rb', line 221
alias flush dummy
#fsync
Alias for #dummy.
# File 'sinatra-contrib/lib/sinatra/streaming.rb', line 222
alias fsync dummy
#getbyte
Alias for #not_open_for_reading.
# File 'sinatra-contrib/lib/sinatra/streaming.rb', line 193
alias getbyte not_open_for_reading
#getc
Alias for #not_open_for_reading.
# File 'sinatra-contrib/lib/sinatra/streaming.rb', line 194
alias getc not_open_for_reading
#gets
Alias for #not_open_for_reading.
# File 'sinatra-contrib/lib/sinatra/streaming.rb', line 195
alias gets not_open_for_reading
#internal_encoding
Alias for #dummy.
# File 'sinatra-contrib/lib/sinatra/streaming.rb', line 223
alias internal_encoding dummy
#lines
Alias for #enum_not_open_for_reading.
# File 'sinatra-contrib/lib/sinatra/streaming.rb', line 217
alias lines enum_not_open_for_reading
#map(&block)
[ GitHub ]# File 'sinatra-contrib/lib/sinatra/streaming.rb', line 117
def map(&block) # dup would not copy the mixin clone.map!(&block) end
#map!(&block)
[ GitHub ]# File 'sinatra-contrib/lib/sinatra/streaming.rb', line 122
def map!(&block) @transformer ||= nil if @transformer inner = @transformer outer = block block = proc { |value| outer[inner[value]] } end @transformer = block self end
#not_open_for_reading (private) Also known as: #bytes, #eof?, #eof, #getbyte, #getc, #gets, #read, #read_nonblock, #readbyte, #readchar, #readline, #readlines, #readpartial, #sysread, #ungetbyte, #ungetc
# File 'sinatra-contrib/lib/sinatra/streaming.rb', line 186
def not_open_for_reading(*) raise IOError, 'not opened for reading' end
#pid
Alias for #dummy.
# File 'sinatra-contrib/lib/sinatra/streaming.rb', line 224
alias pid dummy
#print(*args)
[ GitHub ]# File 'sinatra-contrib/lib/sinatra/streaming.rb', line 142
def print(*args) args.each { |arg| self << arg } nil end
#printf(format, *args)
[ GitHub ]# File 'sinatra-contrib/lib/sinatra/streaming.rb', line 147
def printf(format, *args) print(format.to_s % args) end
#putc(c)
[ GitHub ]# File 'sinatra-contrib/lib/sinatra/streaming.rb', line 151
def putc(c) print c.chr end
#puts(*args)
[ GitHub ]# File 'sinatra-contrib/lib/sinatra/streaming.rb', line 155
def puts(*args) args.each { |arg| self << "#{arg}\n" } nil end
#read
Alias for #not_open_for_reading.
# File 'sinatra-contrib/lib/sinatra/streaming.rb', line 196
alias read not_open_for_reading
#read_nonblock
Alias for #not_open_for_reading.
# File 'sinatra-contrib/lib/sinatra/streaming.rb', line 197
alias read_nonblock not_open_for_reading
#readbyte
Alias for #not_open_for_reading.
# File 'sinatra-contrib/lib/sinatra/streaming.rb', line 198
alias readbyte not_open_for_reading
#readchar
Alias for #not_open_for_reading.
# File 'sinatra-contrib/lib/sinatra/streaming.rb', line 199
alias readchar not_open_for_reading
#readline
Alias for #not_open_for_reading.
# File 'sinatra-contrib/lib/sinatra/streaming.rb', line 200
alias readline not_open_for_reading
#readlines
Alias for #not_open_for_reading.
# File 'sinatra-contrib/lib/sinatra/streaming.rb', line 201
alias readlines not_open_for_reading
#readpartial
Alias for #not_open_for_reading.
# File 'sinatra-contrib/lib/sinatra/streaming.rb', line 202
alias readpartial not_open_for_reading
#rewind
[ GitHub ]# File 'sinatra-contrib/lib/sinatra/streaming.rb', line 182
def rewind @pos = @lineno = 0 end
#seek Also known as: #sysseek
[ GitHub ]# File 'sinatra-contrib/lib/sinatra/streaming.rb', line 227
def seek(*) 0 end
#settings
[ GitHub ]#sync
[ GitHub ]# File 'sinatra-contrib/lib/sinatra/streaming.rb', line 233
def sync true end
#sysread
Alias for #not_open_for_reading.
# File 'sinatra-contrib/lib/sinatra/streaming.rb', line 203
alias sysread not_open_for_reading
#sysseek
Alias for #seek.
# File 'sinatra-contrib/lib/sinatra/streaming.rb', line 231
alias sysseek seek
#syswrite(data)
Alias for #write.
# File 'sinatra-contrib/lib/sinatra/streaming.rb', line 139
alias syswrite write
#ungetbyte
Alias for #not_open_for_reading.
# File 'sinatra-contrib/lib/sinatra/streaming.rb', line 204
alias ungetbyte not_open_for_reading
#ungetc
Alias for #not_open_for_reading.
# File 'sinatra-contrib/lib/sinatra/streaming.rb', line 205
alias ungetc not_open_for_reading
#write(data) Also known as: #syswrite, #write_nonblock
[ GitHub ]# File 'sinatra-contrib/lib/sinatra/streaming.rb', line 134
def write(data) self << data data.to_s.bytesize end
#write_nonblock(data)
Alias for #write.
# File 'sinatra-contrib/lib/sinatra/streaming.rb', line 140
alias write_nonblock write