Class: TelestreamCloud::Uploader::FileReader
- Inherits:
-
Object
- Object
- TelestreamCloud::Uploader::FileReader
- Defined in:
- lib/telestream_cloud/uploader/file_reader.rb
Instance Attribute Summary collapse
-
#file ⇒ Object
readonly
Returns the value of attribute file.
Instance Method Summary collapse
- #[](range) ⇒ Object
-
#initialize(file) ⇒ FileReader
constructor
A new instance of FileReader.
- #name ⇒ Object
- #size ⇒ Object
Constructor Details
#initialize(file) ⇒ FileReader
Returns a new instance of FileReader.
6 7 8 9 |
# File 'lib/telestream_cloud/uploader/file_reader.rb', line 6 def initialize(file) @file = file @mutex = Mutex.new end |
Instance Attribute Details
#file ⇒ Object (readonly)
Returns the value of attribute file.
4 5 6 |
# File 'lib/telestream_cloud/uploader/file_reader.rb', line 4 def file @file end |
Instance Method Details
#[](range) ⇒ Object
11 12 13 14 15 16 |
# File 'lib/telestream_cloud/uploader/file_reader.rb', line 11 def [](range) @mutex.synchronize do file.seek(range.begin) file.read(range.size) end end |
#name ⇒ Object
22 23 24 |
# File 'lib/telestream_cloud/uploader/file_reader.rb', line 22 def name Pathname.new(file.path).basename end |
#size ⇒ Object
18 19 20 |
# File 'lib/telestream_cloud/uploader/file_reader.rb', line 18 def size @size ||= file.size end |