Class: IOStreams::Streams
- Inherits:
-
Object
- Object
- IOStreams::Streams
- Defined in:
- lib/io_streams/streams.rb
Overview
Contains behavior for streams
When a file is being read the streams are processed from right to left. When writing a file streams are processed left to right. For example:
file.gz.enc ==> [:gz, :enc]
Read: Unencrypt, then Gunzip
Write: GZip, then Encrypt
Class Method Summary collapse
-
.streams_for_file_name(file_name) ⇒ Object
Returns [Streams] collection of streams to process against the file.
Instance Method Summary collapse
-
#<<(stream) ⇒ Object
Add another stream for processing.
- #delete(stream) ⇒ Object
- #delimited? ⇒ Boolean
-
#initialize(*args) ⇒ Streams
constructor
Create a processing stream given: - No stream.
-
#unshift(stream) ⇒ Object
Add a stream for processing.
Constructor Details
#initialize(*args) ⇒ Streams
Create a processing stream given:
-
No stream. Defaults to :file
-
A single String implies a file_name and the streams will be created based on the file_name
-
One or more symbols or hashes for a stream
-
One or more arrays for streams
23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 |
# File 'lib/io_streams/streams.rb', line 23 def initialize(*args) if args.size == 0 @streams = [:file] elsif args.size == 1 stream = args.first if stream @stream = stream.is_a?(String) ? streams_for_file_name(stream) : Array(stream) else @streams = [:file] end else @streams = streams end @streams.flatten! end |
Class Method Details
.streams_for_file_name(file_name) ⇒ Object
Returns [Streams] collection of streams to process against the file
14 15 16 |
# File 'lib/io_streams/streams.rb', line 14 def self.streams_for_file_name(file_name) end |
Instance Method Details
#<<(stream) ⇒ Object
Add another stream for processing
48 49 50 |
# File 'lib/io_streams/streams.rb', line 48 def <<(stream) end |
#delete(stream) ⇒ Object
43 44 45 |
# File 'lib/io_streams/streams.rb', line 43 def delete(stream) end |
#delimited? ⇒ Boolean
39 40 41 |
# File 'lib/io_streams/streams.rb', line 39 def delimited? end |
#unshift(stream) ⇒ Object
Add a stream for processing
53 54 55 |
# File 'lib/io_streams/streams.rb', line 53 def unshift(stream) end |