Module: Sinatra::Streaming::Stream
- Defined in:
- lib/rubypitaya/app-template/vendor/bundle/ruby/3.1.0/gems/sinatra-contrib-3.0.5/lib/sinatra/streaming.rb
Instance Attribute Summary collapse
-
#app ⇒ Object
Returns the value of attribute app.
-
#closed ⇒ Object
(also: #closed?)
Returns the value of attribute closed.
-
#lineno ⇒ Object
Returns the value of attribute lineno.
-
#pos ⇒ Object
(also: #tell)
Returns the value of attribute pos.
-
#transformer ⇒ Object
Returns the value of attribute transformer.
Class Method Summary collapse
Instance Method Summary collapse
- #<<(data) ⇒ Object
- #close_read ⇒ Object
- #closed_read? ⇒ Boolean
- #closed_write? ⇒ Boolean
- #dummy ⇒ Object (also: #flush, #fsync, #internal_encoding, #pid)
- #each ⇒ Object
- #enum_not_open_for_reading ⇒ Object (also: #chars, #each_line, #each_byte, #each_char, #lines)
- #external_encoding ⇒ Object
- #map(&block) ⇒ Object
- #map!(&block) ⇒ Object
- #print(*args) ⇒ Object
- #printf(format, *args) ⇒ Object
- #putc(c) ⇒ Object
- #puts(*args) ⇒ Object
- #rewind ⇒ Object
- #seek ⇒ Object (also: #sysseek)
- #settings ⇒ Object
- #sync ⇒ Object
- #tty? ⇒ Boolean (also: #isatty)
- #write(data) ⇒ Object (also: #syswrite, #write_nonblock)
Instance Attribute Details
#app ⇒ Object
Returns the value of attribute app.
88 89 90 |
# File 'lib/rubypitaya/app-template/vendor/bundle/ruby/3.1.0/gems/sinatra-contrib-3.0.5/lib/sinatra/streaming.rb', line 88 def app @app end |
#closed ⇒ Object Also known as: closed?
Returns the value of attribute closed.
88 89 90 |
# File 'lib/rubypitaya/app-template/vendor/bundle/ruby/3.1.0/gems/sinatra-contrib-3.0.5/lib/sinatra/streaming.rb', line 88 def closed @closed end |
#lineno ⇒ Object
Returns the value of attribute lineno.
88 89 90 |
# File 'lib/rubypitaya/app-template/vendor/bundle/ruby/3.1.0/gems/sinatra-contrib-3.0.5/lib/sinatra/streaming.rb', line 88 def lineno @lineno end |
#pos ⇒ Object Also known as: tell
Returns the value of attribute pos.
88 89 90 |
# File 'lib/rubypitaya/app-template/vendor/bundle/ruby/3.1.0/gems/sinatra-contrib-3.0.5/lib/sinatra/streaming.rb', line 88 def pos @pos end |
#transformer ⇒ Object
Returns the value of attribute transformer.
88 89 90 |
# File 'lib/rubypitaya/app-template/vendor/bundle/ruby/3.1.0/gems/sinatra-contrib-3.0.5/lib/sinatra/streaming.rb', line 88 def transformer @transformer end |
Class Method Details
.extended(obj) ⇒ Object
92 93 94 95 96 97 98 |
# File 'lib/rubypitaya/app-template/vendor/bundle/ruby/3.1.0/gems/sinatra-contrib-3.0.5/lib/sinatra/streaming.rb', line 92 def self.extended(obj) obj.closed = false obj.lineno = 0 obj.pos = 0 obj.callback { obj.closed = true } obj.errback { obj.closed = true } end |
Instance Method Details
#<<(data) ⇒ Object
100 101 102 103 104 105 106 107 108 |
# File 'lib/rubypitaya/app-template/vendor/bundle/ruby/3.1.0/gems/sinatra-contrib-3.0.5/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 |
#close_read ⇒ Object
160 161 162 |
# File 'lib/rubypitaya/app-template/vendor/bundle/ruby/3.1.0/gems/sinatra-contrib-3.0.5/lib/sinatra/streaming.rb', line 160 def close_read raise IOError, 'closing non-duplex IO for reading' end |
#closed_read? ⇒ Boolean
164 165 166 |
# File 'lib/rubypitaya/app-template/vendor/bundle/ruby/3.1.0/gems/sinatra-contrib-3.0.5/lib/sinatra/streaming.rb', line 164 def closed_read? true end |
#closed_write? ⇒ Boolean
168 169 170 |
# File 'lib/rubypitaya/app-template/vendor/bundle/ruby/3.1.0/gems/sinatra-contrib-3.0.5/lib/sinatra/streaming.rb', line 168 def closed_write? closed? end |
#dummy ⇒ Object Also known as: flush, fsync, internal_encoding, pid
220 |
# File 'lib/rubypitaya/app-template/vendor/bundle/ruby/3.1.0/gems/sinatra-contrib-3.0.5/lib/sinatra/streaming.rb', line 220 def dummy(*) end |
#each ⇒ Object
110 111 112 113 114 115 |
# File 'lib/rubypitaya/app-template/vendor/bundle/ruby/3.1.0/gems/sinatra-contrib-3.0.5/lib/sinatra/streaming.rb', line 110 def each # that way body.each.map { ... } works return self unless block_given? super end |
#enum_not_open_for_reading ⇒ Object Also known as: chars, each_line, each_byte, each_char, lines
208 209 210 211 |
# File 'lib/rubypitaya/app-template/vendor/bundle/ruby/3.1.0/gems/sinatra-contrib-3.0.5/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 |
#external_encoding ⇒ Object
172 173 174 175 176 |
# File 'lib/rubypitaya/app-template/vendor/bundle/ruby/3.1.0/gems/sinatra-contrib-3.0.5/lib/sinatra/streaming.rb', line 172 def external_encoding Encoding.find settings.default_encoding rescue NameError settings.default_encoding end |
#map(&block) ⇒ Object
117 118 119 120 |
# File 'lib/rubypitaya/app-template/vendor/bundle/ruby/3.1.0/gems/sinatra-contrib-3.0.5/lib/sinatra/streaming.rb', line 117 def map(&block) # dup would not copy the mixin clone.map!(&block) end |
#map!(&block) ⇒ Object
122 123 124 125 126 127 128 129 130 131 132 |
# File 'lib/rubypitaya/app-template/vendor/bundle/ruby/3.1.0/gems/sinatra-contrib-3.0.5/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 |
#print(*args) ⇒ Object
142 143 144 145 |
# File 'lib/rubypitaya/app-template/vendor/bundle/ruby/3.1.0/gems/sinatra-contrib-3.0.5/lib/sinatra/streaming.rb', line 142 def print(*args) args.each { |arg| self << arg } nil end |
#printf(format, *args) ⇒ Object
147 148 149 |
# File 'lib/rubypitaya/app-template/vendor/bundle/ruby/3.1.0/gems/sinatra-contrib-3.0.5/lib/sinatra/streaming.rb', line 147 def printf(format, *args) print(format.to_s % args) end |
#putc(c) ⇒ Object
151 152 153 |
# File 'lib/rubypitaya/app-template/vendor/bundle/ruby/3.1.0/gems/sinatra-contrib-3.0.5/lib/sinatra/streaming.rb', line 151 def putc(c) print c.chr end |
#puts(*args) ⇒ Object
155 156 157 158 |
# File 'lib/rubypitaya/app-template/vendor/bundle/ruby/3.1.0/gems/sinatra-contrib-3.0.5/lib/sinatra/streaming.rb', line 155 def puts(*args) args.each { |arg| self << "#{arg}\n" } nil end |
#rewind ⇒ Object
182 183 184 |
# File 'lib/rubypitaya/app-template/vendor/bundle/ruby/3.1.0/gems/sinatra-contrib-3.0.5/lib/sinatra/streaming.rb', line 182 def rewind @pos = @lineno = 0 end |
#seek ⇒ Object Also known as: sysseek
227 228 229 |
# File 'lib/rubypitaya/app-template/vendor/bundle/ruby/3.1.0/gems/sinatra-contrib-3.0.5/lib/sinatra/streaming.rb', line 227 def seek(*) 0 end |
#settings ⇒ Object
178 179 180 |
# File 'lib/rubypitaya/app-template/vendor/bundle/ruby/3.1.0/gems/sinatra-contrib-3.0.5/lib/sinatra/streaming.rb', line 178 def settings app.settings end |
#sync ⇒ Object
233 234 235 |
# File 'lib/rubypitaya/app-template/vendor/bundle/ruby/3.1.0/gems/sinatra-contrib-3.0.5/lib/sinatra/streaming.rb', line 233 def sync true end |
#tty? ⇒ Boolean Also known as: isatty
237 238 239 |
# File 'lib/rubypitaya/app-template/vendor/bundle/ruby/3.1.0/gems/sinatra-contrib-3.0.5/lib/sinatra/streaming.rb', line 237 def tty? false end |
#write(data) ⇒ Object Also known as: syswrite, write_nonblock
134 135 136 137 |
# File 'lib/rubypitaya/app-template/vendor/bundle/ruby/3.1.0/gems/sinatra-contrib-3.0.5/lib/sinatra/streaming.rb', line 134 def write(data) self << data data.to_s.bytesize end |