class Tr4n5l4te::Agent
Constants
- DEFAULT_UA
rubocop:disable Metrics/LineLength
Attributes
browser[R]
rubocop:enable Metrics/LineLength
Public Class Methods
new(options = {})
click to toggle source
# File lib/tr4n5l4te/agent.rb, line 28 def initialize(options = {}) Capybara.ignore_hidden_elements = false @browser = options[:browser] || Capybara.current_session browser.driver.headers = { 'User-Agent' => DEFAULT_UA } end
Public Instance Methods
body()
click to toggle source
# File lib/tr4n5l4te/agent.rb, line 81 def body browser.body end
elements(selector_string)
click to toggle source
# File lib/tr4n5l4te/agent.rb, line 85 def elements(selector_string) browser.all(selector_string) end
visit(url)
click to toggle source
# File lib/tr4n5l4te/agent.rb, line 76 def visit(url) response = browser.visit(url) response.recursively_symbolize_keys! end
Private Instance Methods
days(num)
click to toggle source
# File lib/tr4n5l4te/agent.rb, line 95 def days(num) num * 86_400 end
time_plus_years(years = 30)
click to toggle source
# File lib/tr4n5l4te/agent.rb, line 91 def time_plus_years(years = 30) Time.now + days(365) * years end