Class: Stdout::Buffered
Constant Summary collapse
- MIN_FRAME_LENGTH =
1.0 / 60
Instance Attribute Summary collapse
-
#stdout ⇒ Object
readonly
Returns the value of attribute stdout.
Instance Method Summary collapse
- #each {|buffered_delay, buffered_data.join| ... } ⇒ Object
-
#initialize(stdout) ⇒ Buffered
constructor
A new instance of Buffered.
Constructor Details
#initialize(stdout) ⇒ Buffered
Returns a new instance of Buffered.
78 79 80 |
# File 'lib/asciinema/stdout.rb', line 78 def initialize(stdout) @stdout = stdout end |
Instance Attribute Details
#stdout ⇒ Object (readonly)
Returns the value of attribute stdout.
76 77 78 |
# File 'lib/asciinema/stdout.rb', line 76 def stdout @stdout end |
Instance Method Details
#each {|buffered_delay, buffered_data.join| ... } ⇒ Object
82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 |
# File 'lib/asciinema/stdout.rb', line 82 def each buffered_delay, buffered_data = 0.0, [] stdout.each do |delay, data| if buffered_delay + delay < MIN_FRAME_LENGTH || buffered_data.empty? buffered_delay += delay buffered_data << data else yield(buffered_delay, buffered_data.join) buffered_delay = delay buffered_data = [data] end end yield(buffered_delay, buffered_data.join) unless buffered_data.empty? end |