Class: Virgil::Crypto::VirgilStreamDataSource
- Inherits:
-
Core::VirgilDataSource
- Object
- Core::VirgilDataSource
- Virgil::Crypto::VirgilStreamDataSource
- Defined in:
- lib/virgil/crypto/stream_data_source.rb
Instance Attribute Summary collapse
-
#buffer_size ⇒ Object
readonly
Returns the value of attribute buffer_size.
-
#stream ⇒ Object
readonly
Returns the value of attribute stream.
Instance Method Summary collapse
- #has_data ⇒ Object
-
#initialize(stream, buffer_size = 1024) ⇒ VirgilStreamDataSource
constructor
A new instance of VirgilStreamDataSource.
- #read ⇒ Object
Constructor Details
#initialize(stream, buffer_size = 1024) ⇒ VirgilStreamDataSource
Returns a new instance of VirgilStreamDataSource.
40 41 42 43 44 |
# File 'lib/virgil/crypto/stream_data_source.rb', line 40 def initialize(stream, buffer_size = 1024) @stream = stream @buffer_size = buffer_size super() end |
Instance Attribute Details
#buffer_size ⇒ Object (readonly)
Returns the value of attribute buffer_size.
38 39 40 |
# File 'lib/virgil/crypto/stream_data_source.rb', line 38 def buffer_size @buffer_size end |
#stream ⇒ Object (readonly)
Returns the value of attribute stream.
38 39 40 |
# File 'lib/virgil/crypto/stream_data_source.rb', line 38 def stream @stream end |
Instance Method Details
#has_data ⇒ Object
46 47 48 |
# File 'lib/virgil/crypto/stream_data_source.rb', line 46 def has_data !stream.closed? && !stream.eof? end |
#read ⇒ Object
50 51 52 |
# File 'lib/virgil/crypto/stream_data_source.rb', line 50 def read Bytes.from_string(stream.read(buffer_size)) end |