Class: TelestreamCloud::Tts::Uploader::FileReader
- Inherits:
-
Object
- Object
- TelestreamCloud::Tts::Uploader::FileReader
- Defined in:
- lib/telestream_cloud_tts/uploader.rb
Instance Attribute Summary collapse
-
#file ⇒ Object
readonly
Returns the value of attribute file.
Instance Method Summary collapse
- #[](range) ⇒ Object
- #close ⇒ Object
-
#initialize(path) ⇒ FileReader
constructor
A new instance of FileReader.
- #name ⇒ Object
- #reopen ⇒ Object
- #size ⇒ Object
Constructor Details
#initialize(path) ⇒ FileReader
Returns a new instance of FileReader.
10 11 12 13 14 |
# File 'lib/telestream_cloud_tts/uploader.rb', line 10 def initialize(path) @mutex = Mutex.new @path = path reopen end |
Instance Attribute Details
#file ⇒ Object (readonly)
Returns the value of attribute file.
8 9 10 |
# File 'lib/telestream_cloud_tts/uploader.rb', line 8 def file @file end |
Instance Method Details
#[](range) ⇒ Object
16 17 18 19 20 21 |
# File 'lib/telestream_cloud_tts/uploader.rb', line 16 def [](range) @mutex.synchronize do file.seek(range.begin) file.read(range.size) end end |
#close ⇒ Object
31 32 33 34 |
# File 'lib/telestream_cloud_tts/uploader.rb', line 31 def close @file.close @file = nil end |
#name ⇒ Object
27 28 29 |
# File 'lib/telestream_cloud_tts/uploader.rb', line 27 def name Pathname.new(file.path).basename end |
#reopen ⇒ Object
36 37 38 |
# File 'lib/telestream_cloud_tts/uploader.rb', line 36 def reopen @file ||= File.open(@path) end |
#size ⇒ Object
23 24 25 |
# File 'lib/telestream_cloud_tts/uploader.rb', line 23 def size @size ||= file.size end |