Module: MechanizeClip
- Defined in:
- lib/mechanize_clip.rb,
lib/mechanize_clip/version.rb
Defined Under Namespace
Classes: PageTmpFile, RawTmpFile
Constant Summary collapse
- VERSION =
"0.1.2"
Class Method Summary collapse
- .from_raw(request, filename_param = 'qqfile') ⇒ Object
-
.get(url) ⇒ Object
Downloads url contents to temp file using Mechanize returns nil if something bad happend.
-
.get!(url) ⇒ Object
Downloads url contents to temp file using Mechanize raise exception if something bad happend.
Class Method Details
.from_raw(request, filename_param = 'qqfile') ⇒ Object
74 75 76 77 78 79 80 |
# File 'lib/mechanize_clip.rb', line 74 def from_raw request, filename_param = 'qqfile' if request.params[filename_param].respond_to?(:original_filename) request.params[filename_param] else RawTmpFile.new request, "_#{filename_param}" end end |
.get(url) ⇒ Object
Downloads url contents to temp file using Mechanize returns nil if something bad happend
58 59 60 61 62 63 64 |
# File 'lib/mechanize_clip.rb', line 58 def get url begin get! url rescue nil end end |
.get!(url) ⇒ Object
Downloads url contents to temp file using Mechanize raise exception if something bad happend
68 69 70 71 72 |
# File 'lib/mechanize_clip.rb', line 68 def get! url agent = Mechanize.new # agent.max_file_buffer = 0 # always download to temp file PageTmpFile.new agent.get(url) end |