Class: Capture
- Inherits:
-
Object
- Object
- Capture
- Defined in:
- lib/capture.rb
Constant Summary collapse
- API_URL =
"https://cdn.capture.page"- EDGE_URL =
"https://edge.capture.page"
Instance Attribute Summary collapse
-
#key ⇒ Object
readonly
Returns the value of attribute key.
-
#options ⇒ Object
readonly
Returns the value of attribute options.
Instance Method Summary collapse
- #build_animated_url(url, options = {}) ⇒ Object
- #build_content_url(url, options = {}) ⇒ Object
- #build_image_url(url, options = {}) ⇒ Object
- #build_metadata_url(url, options = {}) ⇒ Object
- #build_pdf_url(url, options = {}) ⇒ Object
- #close_session(session_id) ⇒ Object
- #create_session(options = {}) ⇒ Object
- #execute_action(session_id, action_type, payload = {}) ⇒ Object
- #fetch_animated(url, options = {}) ⇒ Object
- #fetch_content(url, options = {}) ⇒ Object
- #fetch_image(url, options = {}) ⇒ Object
- #fetch_metadata(url, options = {}) ⇒ Object
- #fetch_pdf(url, options = {}) ⇒ Object
- #get_session(session_id) ⇒ Object
-
#initialize(key, secret, options = {}) ⇒ Capture
constructor
A new instance of Capture.
Constructor Details
#initialize(key, secret, options = {}) ⇒ Capture
Returns a new instance of Capture.
25 26 27 28 29 30 31 |
# File 'lib/capture.rb', line 25 def initialize(key, secret, = {}) @key = key @secret = secret = .nil? ? {} : raise TypeError, "options must be a Hash" unless .is_a?(Hash) @options = end |
Instance Attribute Details
#key ⇒ Object (readonly)
Returns the value of attribute key.
23 24 25 |
# File 'lib/capture.rb', line 23 def key @key end |
#options ⇒ Object (readonly)
Returns the value of attribute options.
23 24 25 |
# File 'lib/capture.rb', line 23 def @options end |
Instance Method Details
#build_animated_url(url, options = {}) ⇒ Object
49 50 51 |
# File 'lib/capture.rb', line 49 def build_animated_url(url, = {}) build_url(url, "animated", ) end |
#build_content_url(url, options = {}) ⇒ Object
41 42 43 |
# File 'lib/capture.rb', line 41 def build_content_url(url, = {}) build_url(url, "content", ) end |
#build_image_url(url, options = {}) ⇒ Object
33 34 35 |
# File 'lib/capture.rb', line 33 def build_image_url(url, = {}) build_url(url, "image", ) end |
#build_metadata_url(url, options = {}) ⇒ Object
45 46 47 |
# File 'lib/capture.rb', line 45 def (url, = {}) build_url(url, "metadata", ) end |
#build_pdf_url(url, options = {}) ⇒ Object
37 38 39 |
# File 'lib/capture.rb', line 37 def build_pdf_url(url, = {}) build_url(url, "pdf", ) end |
#close_session(session_id) ⇒ Object
84 85 86 |
# File 'lib/capture.rb', line 84 def close_session(session_id) sessions_request("/#{escape_path(session_id)}", :delete) end |
#create_session(options = {}) ⇒ Object
73 74 75 76 77 78 |
# File 'lib/capture.rb', line 73 def create_session( = {}) = .nil? ? {} : raise TypeError, "options must be a Hash" unless .is_a?(Hash) sessions_request("", :post, ) end |
#execute_action(session_id, action_type, payload = {}) ⇒ Object
88 89 90 91 92 93 |
# File 'lib/capture.rb', line 88 def execute_action(session_id, action_type, payload = {}) payload = payload.nil? ? {} : payload raise TypeError, "payload must be a Hash" unless payload.is_a?(Hash) sessions_request("/#{escape_path(session_id)}/actions", :post, "type" => action_type, "payload" => payload) end |
#fetch_animated(url, options = {}) ⇒ Object
69 70 71 |
# File 'lib/capture.rb', line 69 def fetch_animated(url, = {}) fetch_binary(build_animated_url(url, )) end |
#fetch_content(url, options = {}) ⇒ Object
61 62 63 |
# File 'lib/capture.rb', line 61 def fetch_content(url, = {}) fetch_json(build_content_url(url, )) end |
#fetch_image(url, options = {}) ⇒ Object
53 54 55 |
# File 'lib/capture.rb', line 53 def fetch_image(url, = {}) fetch_binary(build_image_url(url, )) end |
#fetch_metadata(url, options = {}) ⇒ Object
65 66 67 |
# File 'lib/capture.rb', line 65 def (url, = {}) fetch_json((url, )) end |
#fetch_pdf(url, options = {}) ⇒ Object
57 58 59 |
# File 'lib/capture.rb', line 57 def fetch_pdf(url, = {}) fetch_binary(build_pdf_url(url, )) end |
#get_session(session_id) ⇒ Object
80 81 82 |
# File 'lib/capture.rb', line 80 def get_session(session_id) sessions_request("/#{escape_path(session_id)}", :get) end |