Class: Capture

Inherits:
Object
  • Object
show all
Defined in:
lib/capture.rb

Constant Summary collapse

API_URL =
"https://cdn.capture.page"
EDGE_URL =
"https://edge.capture.page"

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(key, secret, options = {}) ⇒ Capture

Returns a new instance of Capture.

Raises:

  • (TypeError)


53
54
55
56
57
58
59
60
# File 'lib/capture.rb', line 53

def initialize(key, secret, options = {})
  @key = key
  @secret = secret
  options = options.nil? ? {} : options
  raise TypeError, "options must be a Hash" unless options.is_a?(Hash)
  @options = options
  @sessions = CaptureSessions.new(self)
end

Instance Attribute Details

#keyObject (readonly)

Returns the value of attribute key.



51
52
53
# File 'lib/capture.rb', line 51

def key
  @key
end

#optionsObject (readonly)

Returns the value of attribute options.



51
52
53
# File 'lib/capture.rb', line 51

def options
  @options
end

#sessionsObject (readonly)

Returns the value of attribute sessions.



51
52
53
# File 'lib/capture.rb', line 51

def sessions
  @sessions
end

Instance Method Details

#build_animated_url(url, options = {}) ⇒ Object



78
79
80
# File 'lib/capture.rb', line 78

def build_animated_url(url, options = {})
  build_url(url, "animated", options)
end

#build_content_url(url, options = {}) ⇒ Object



70
71
72
# File 'lib/capture.rb', line 70

def build_content_url(url, options = {})
  build_url(url, "content", options)
end

#build_image_url(url, options = {}) ⇒ Object



62
63
64
# File 'lib/capture.rb', line 62

def build_image_url(url, options = {})
  build_url(url, "image", options)
end

#build_metadata_url(url, options = {}) ⇒ Object



74
75
76
# File 'lib/capture.rb', line 74

def (url, options = {})
  build_url(url, "metadata", options)
end

#build_pdf_url(url, options = {}) ⇒ Object



66
67
68
# File 'lib/capture.rb', line 66

def build_pdf_url(url, options = {})
  build_url(url, "pdf", options)
end

#fetch_animated(url, options = {}) ⇒ Object



98
99
100
# File 'lib/capture.rb', line 98

def fetch_animated(url, options = {})
  fetch_binary(build_animated_url(url, options))
end

#fetch_content(url, options = {}) ⇒ Object



90
91
92
# File 'lib/capture.rb', line 90

def fetch_content(url, options = {})
  fetch_json(build_content_url(url, options))
end

#fetch_image(url, options = {}) ⇒ Object



82
83
84
# File 'lib/capture.rb', line 82

def fetch_image(url, options = {})
  fetch_binary(build_image_url(url, options))
end

#fetch_metadata(url, options = {}) ⇒ Object



94
95
96
# File 'lib/capture.rb', line 94

def (url, options = {})
  fetch_json((url, options))
end

#fetch_pdf(url, options = {}) ⇒ Object



86
87
88
# File 'lib/capture.rb', line 86

def fetch_pdf(url, options = {})
  fetch_binary(build_pdf_url(url, options))
end