Class: BoringBackup::Tee
- Inherits:
-
Object
- Object
- BoringBackup::Tee
- Defined in:
- lib/boring_backup/tee.rb
Defined Under Namespace
Classes: Sink
Instance Attribute Summary collapse
-
#bytes ⇒ Object
readonly
Returns the value of attribute bytes.
Instance Method Summary collapse
-
#initialize(sinks, progress: nil) ⇒ Tee
constructor
A new instance of Tee.
- #write(chunk) ⇒ Object
Constructor Details
#initialize(sinks, progress: nil) ⇒ Tee
Returns a new instance of Tee.
27 28 29 30 31 |
# File 'lib/boring_backup/tee.rb', line 27 def initialize(sinks, progress: nil) @sinks = sinks @progress = progress @bytes = 0 end |
Instance Attribute Details
#bytes ⇒ Object (readonly)
Returns the value of attribute bytes.
25 26 27 |
# File 'lib/boring_backup/tee.rb', line 25 def bytes @bytes end |
Instance Method Details
#write(chunk) ⇒ Object
33 34 35 36 37 38 39 40 |
# File 'lib/boring_backup/tee.rb', line 33 def write(chunk) @sinks.each { |sink| sink.write(chunk) } @bytes += chunk.bytesize @progress&.call(@bytes) chunk.bytesize end |