Class: ConvertApi::ResultFile
- Inherits:
-
Object
- Object
- ConvertApi::ResultFile
- Defined in:
- lib/convert_api/result_file.rb
Instance Attribute Summary collapse
-
#info ⇒ Object
readonly
Returns the value of attribute info.
Instance Method Summary collapse
- #filename ⇒ Object
-
#initialize(info) ⇒ ResultFile
constructor
A new instance of ResultFile.
- #io ⇒ Object
- #save(path) ⇒ Object
- #size ⇒ Object
- #url ⇒ Object
Constructor Details
#initialize(info) ⇒ ResultFile
Returns a new instance of ResultFile.
7 8 9 |
# File 'lib/convert_api/result_file.rb', line 7 def initialize(info) @info = info end |
Instance Attribute Details
#info ⇒ Object (readonly)
Returns the value of attribute info.
5 6 7 |
# File 'lib/convert_api/result_file.rb', line 5 def info @info end |
Instance Method Details
#filename ⇒ Object
15 16 17 |
# File 'lib/convert_api/result_file.rb', line 15 def filename info['FileName'] end |
#io ⇒ Object
23 24 25 |
# File 'lib/convert_api/result_file.rb', line 23 def io @io ||= URI.parse(url).open() end |
#save(path) ⇒ Object
27 28 29 30 31 32 33 |
# File 'lib/convert_api/result_file.rb', line 27 def save(path) path = File.join(path, filename) if File.directory?(path) IO.copy_stream(io, path, size) path end |
#size ⇒ Object
19 20 21 |
# File 'lib/convert_api/result_file.rb', line 19 def size info['FileSize'] end |
#url ⇒ Object
11 12 13 |
# File 'lib/convert_api/result_file.rb', line 11 def url info['Url'] end |