Class: TemplateStreaming::StreamingBody
- Inherits:
-
Object
- Object
- TemplateStreaming::StreamingBody
- Defined in:
- lib/template_streaming.rb
Instance Method Summary collapse
- #each(&block) ⇒ Object
-
#initialize(threshold, &block) ⇒ StreamingBody
constructor
A new instance of StreamingBody.
- #push(data) ⇒ Object
Constructor Details
#initialize(threshold, &block) ⇒ StreamingBody
Returns a new instance of StreamingBody.
236 237 238 239 |
# File 'lib/template_streaming.rb', line 236 def initialize(threshold, &block) @process = block @bytes_to_threshold = threshold end |
Instance Method Details
#each(&block) ⇒ Object
241 242 243 244 |
# File 'lib/template_streaming.rb', line 241 def each(&block) @push = block @process.call end |
#push(data) ⇒ Object
246 247 248 249 250 251 252 253 |
# File 'lib/template_streaming.rb', line 246 def push(data) if @bytes_to_threshold > 0 @push.call(data + padding) @bytes_to_threshold = 0 else @push.call(data) end end |