Class: Makuri::Browser
- Inherits:
-
Object
- Object
- Makuri::Browser
- Defined in:
- lib/makuri/browser.rb
Instance Attribute Summary collapse
-
#current_url ⇒ Object
Returns the value of attribute current_url.
-
#render_js ⇒ Object
Returns the value of attribute render_js.
-
#request_body ⇒ Object
Returns the value of attribute request_body.
-
#request_method ⇒ Object
Returns the value of attribute request_method.
-
#user_agent ⇒ Object
Returns the value of attribute user_agent.
Instance Method Summary collapse
- #follow(url = '') ⇒ Object
-
#initialize(options = {}) ⇒ Browser
constructor
A new instance of Browser.
Constructor Details
#initialize(options = {}) ⇒ Browser
Returns a new instance of Browser.
5 6 7 8 9 10 11 12 13 14 15 |
# File 'lib/makuri/browser.rb', line 5 def initialize( = {}) @current_url = .fetch(:url, '') @request_method = .fetch(:request_method, :get) @request_body = .fetch(:request_body, {}) @render_js = .fetch(:render_js, false) @user_agent = .fetch( :user_agent, 'Mozilla/5.0 (X11; Linux x86_64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/86.0.4240.111 Safari/537.36' ) end |
Instance Attribute Details
#current_url ⇒ Object
Returns the value of attribute current_url.
3 4 5 |
# File 'lib/makuri/browser.rb', line 3 def current_url @current_url end |
#render_js ⇒ Object
Returns the value of attribute render_js.
3 4 5 |
# File 'lib/makuri/browser.rb', line 3 def render_js @render_js end |
#request_body ⇒ Object
Returns the value of attribute request_body.
3 4 5 |
# File 'lib/makuri/browser.rb', line 3 def request_body @request_body end |
#request_method ⇒ Object
Returns the value of attribute request_method.
3 4 5 |
# File 'lib/makuri/browser.rb', line 3 def request_method @request_method end |
#user_agent ⇒ Object
Returns the value of attribute user_agent.
3 4 5 |
# File 'lib/makuri/browser.rb', line 3 def user_agent @user_agent end |
Instance Method Details
#follow(url = '') ⇒ Object
17 18 19 20 21 22 23 |
# File 'lib/makuri/browser.rb', line 17 def follow(url = '') @current_url = url unless url.empty? raise 'Invalid URL supplied' if @current_url.empty? @browser = create_browser @browser.visit(@current_url) end |