Class: Virgil::Crypto::VirgilStreamDataSource

Inherits:
Core::VirgilDataSource
  • Object
show all
Defined in:
lib/virgil/crypto/stream_data_source.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

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_sizeObject (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

#streamObject (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_dataObject



46
47
48
# File 'lib/virgil/crypto/stream_data_source.rb', line 46

def has_data
  !stream.closed? && !stream.eof?
end

#readObject



50
51
52
# File 'lib/virgil/crypto/stream_data_source.rb', line 50

def read
  Bytes.from_string(stream.read(buffer_size))
end