Class: Rstreamor::File
- Inherits:
-
Object
- Object
- Rstreamor::File
- Defined in:
- lib/rstreamor/file.rb
Instance Attribute Summary collapse
-
#file ⇒ Object
readonly
Returns the value of attribute file.
Instance Method Summary collapse
- #content_type ⇒ Object
- #data ⇒ Object
-
#initialize(file) ⇒ File
constructor
A new instance of File.
- #size ⇒ Object
Constructor Details
#initialize(file) ⇒ File
Returns a new instance of File.
5 6 7 |
# File 'lib/rstreamor/file.rb', line 5 def initialize(file) @file = file end |
Instance Attribute Details
#file ⇒ Object (readonly)
Returns the value of attribute file.
3 4 5 |
# File 'lib/rstreamor/file.rb', line 3 def file @file end |
Instance Method Details
#content_type ⇒ Object
17 18 19 |
# File 'lib/rstreamor/file.rb', line 17 def content_type file.content_type end |
#data ⇒ Object
9 10 11 12 13 14 15 |
# File 'lib/rstreamor/file.rb', line 9 def data @data ||= if file.respond_to? :data file.data else file.read end end |
#size ⇒ Object
21 22 23 24 25 26 27 |
# File 'lib/rstreamor/file.rb', line 21 def size # Because of encoding, the string size might not match the stream size, # and that may lead to files being truncated when served (i.e. this happens # often for MP3 files, were the last few seconds of files longer than a minute # gets trimmed). @size ||= data.bytesize end |