Class: Helpers::SubStreamView
- Inherits:
-
BaseStreamView
- Object
- BaseStreamView
- Helpers::SubStreamView
- Defined in:
- lib/file_data/helpers/stream_view.rb
Overview
View of a stream that has a specified size in bytes
Instance Attribute Summary collapse
-
#end_pos ⇒ Object
readonly
Returns the value of attribute end_pos.
-
#size ⇒ Object
readonly
Returns the value of attribute size.
Attributes inherited from BaseStreamView
Instance Method Summary collapse
- #eof? ⇒ Boolean
-
#initialize(stream, start_pos, size) ⇒ SubStreamView
constructor
A new instance of SubStreamView.
- #remaining_bytes ⇒ Object
Methods included from BinaryExtensions
Constructor Details
#initialize(stream, start_pos, size) ⇒ SubStreamView
Returns a new instance of SubStreamView.
24 25 26 27 28 |
# File 'lib/file_data/helpers/stream_view.rb', line 24 def initialize(stream, start_pos, size) super(stream, start_pos) @end_pos = @start_pos + size - 1 @size = size end |
Instance Attribute Details
#end_pos ⇒ Object (readonly)
Returns the value of attribute end_pos.
22 23 24 |
# File 'lib/file_data/helpers/stream_view.rb', line 22 def end_pos @end_pos end |
#size ⇒ Object (readonly)
Returns the value of attribute size.
22 23 24 |
# File 'lib/file_data/helpers/stream_view.rb', line 22 def size @size end |
Instance Method Details
#eof? ⇒ Boolean
34 35 36 |
# File 'lib/file_data/helpers/stream_view.rb', line 34 def eof? pos > @end_pos || @stream.eof? end |
#remaining_bytes ⇒ Object
30 31 32 |
# File 'lib/file_data/helpers/stream_view.rb', line 30 def remaining_bytes @end_pos - pos + 1 end |