Module: Devry::Helpers

Included in:
Job, Job
Defined in:
lib/devry.rb

Instance Method Summary collapse

Instance Method Details

#agentObject



26
27
28
# File 'lib/devry.rb', line 26

def agent
  @agent ||= Mechanize.new
end

#extract_text(element) ⇒ Object



7
8
9
10
# File 'lib/devry.rb', line 7

def extract_text(element)
  return nil if element.nil?
  element.text.strip
end

#extract_time(element) ⇒ Object



12
13
14
15
# File 'lib/devry.rb', line 12

def extract_time(element)
  return nil if element.nil?
  Time.parse(extract_text(element))
end

#extract_url(element) ⇒ Object



17
18
19
20
# File 'lib/devry.rb', line 17

def extract_url(element)
  return nil if element.nil?
  element.at("a")['href']
end

#fetch_page(url) ⇒ Object



22
23
24
# File 'lib/devry.rb', line 22

def fetch_page(url)
  agent.get(url)
end