Class: Simplificator::Webthumb::Webthumb
- Defined in:
- lib/rwebthumb/webthumb.rb
Overview
Main access point for the webthumb API. All methods calling the Server need the api key beeing set.
Constant Summary
Constants inherited from Base
Base::VALID_OUTPUT_TYPES, Base::VALID_SIZES
Instance Attribute Summary
Attributes inherited from Base
Instance Method Summary collapse
-
#credits ⇒ Object
Check your credit status on the webthumbs server Returns a hash with two keys.
-
#job_status(job_id) ⇒ Object
Request the job status from server.
-
#thumbnail(options = {}) ⇒ Object
Request thumbnail creation from webthumb server.
Methods inherited from Base
#build_root_node, #do_request, #initialize, parse_webthumb_datetime
Constructor Details
This class inherits a constructor from Simplificator::Webthumb::Base
Instance Method Details
#credits ⇒ Object
Check your credit status on the webthumbs server Returns a hash with two keys. See webthumb API for detailed information.
-
reserve: an integer
-
subscription: an integer
51 52 53 54 55 |
# File 'lib/rwebthumb/webthumb.rb', line 51 def credits() response = do_request(build_credits_xml()) credit_elements = REXML::XPath.first(response, '/webthumb/credits').elements {:reserve => credit_elements['reserve'].text.to_i, :subscription => credit_elements['subscription'].text.to_i} end |
#job_status(job_id) ⇒ Object
Request the job status from server. This can be used to look up job status from server when you just have the job ID, e.g. when you want to retrieve the thumbs later or when you use callbacks. The Job object returned from this method does not have all attributes set since. Webthumbs API does not return the requested URL, the duration estimation and the cost values when checking the status. I hope this will change someday.
42 43 44 45 |
# File 'lib/rwebthumb/webthumb.rb', line 42 def job_status(job_id) raise WebthumbException.new('Job id is required') if job_id == nil || job_id == '' Job.from_status_xml(@api_key, do_request(build_job_status_xml(job_id))) end |
#thumbnail(options = {}) ⇒ Object
Request thumbnail creation from webthumb server. A Job object holding request information is returned (most important the job_id) Some keys have been ruby-ized (i.e. outputType -> :output_type). All keys are Symbols. Check out the webthumb API description for detailed explanation of the options webthumb.bluga.net/apidoc Options:
-
url: the url to take the snapshot from
-
output_type: chose output format (jpg or png)
-
width: width of the browser
-
height: height of the browser
-
fullthumb: full sized snapshot (true or false)
-
custom_thumbnail: create a custom sized thumbnail. A hash with width and height entries
-
effect: specify a visual effect (mirror, dropshadow or border)
-
delay: wait until the snapshot is taken
-
notify: callback url which is called after snapshot is taken
-
excerpt: taking an excerpt snapshot. A hash with for entries. width, height, x, y
-
videothumb: experimental option, check Joshs blog (blog.joshuaeichorn.com/archives/2008/07/08/videothumb-addon-to-webthumb-is-alpha/) (true or false)
Only the url option is required. Check webthumb API for default values. Check also the different constants defined in Base.rb for valid values
33 34 35 |
# File 'lib/rwebthumb/webthumb.rb', line 33 def thumbnail( = {}) Job.from_thumbnail_xml(@api_key, do_request(build_thumbnail_xml())) end |