Class: HypermediaAPI::Document
- Inherits:
-
Object
- Object
- HypermediaAPI::Document
- Includes:
- HypermediaAPI
- Defined in:
- lib/api/document.rb
Constant Summary
Constants included from HypermediaAPI
Class Method Summary collapse
Instance Method Summary collapse
- #form(css_selector) ⇒ Object
- #headers ⇒ Object
- #html ⇒ Object
-
#initialize(httparty_nokogiri_document) ⇒ Document
constructor
A new instance of Document.
- #status ⇒ Object
Methods included from HypermediaAPI
Constructor Details
#initialize(httparty_nokogiri_document) ⇒ Document
Returns a new instance of Document.
30 31 32 |
# File 'lib/api/document.rb', line 30 def initialize (httparty_nokogiri_document) @document = httparty_nokogiri_document end |
Class Method Details
.click(url) ⇒ Object
6 7 8 9 |
# File 'lib/api/document.rb', line 6 def Document.click (url) response = Document.get(url) Document.new(response) end |
Instance Method Details
#form(css_selector) ⇒ Object
11 12 13 14 15 16 17 18 19 20 |
# File 'lib/api/document.rb', line 11 def form (css_selector) if form_element = @document.css(css_selector).first action_uri = form_element['action'] http_method = form_element['method'].downcase Form.new(action_uri, http_method) else raise MissingForm, "The API does not have a form matching '#{css_selector}' at #{@document.path}." end end |
#headers ⇒ Object
22 23 24 |
# File 'lib/api/document.rb', line 22 def headers @document.headers end |
#html ⇒ Object
26 27 28 |
# File 'lib/api/document.rb', line 26 def html @document.to_html end |
#status ⇒ Object
34 35 36 |
# File 'lib/api/document.rb', line 34 def status @document.code end |