Class: JobParser::Parser

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

Direct Known Subclasses

ParseHtml, ParseSchema

Constant Summary collapse

ACCEPTED_ELEMENTS =
%w{p a h1 h2 h3 h4 h5 span dl dd dt td}

Instance Method Summary collapse

Constructor Details

#initialize(html, from_url) ⇒ Parser

Returns a new instance of Parser.



6
7
8
9
10
11
# File 'lib/jobparser/parser.rb', line 6

def initialize(html, from_url)
  @url = from_url
  @html = html
  @doc = strip_bad_elements(Nokogiri::HTML(@html))
  @plain_text = get_plain_text
end

Instance Method Details

#jobObject



13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
# File 'lib/jobparser/parser.rb', line 13

def job
  if JobParser.cache.valid_for_url?(@url)
    JobParser.cache.fetch_result_for_url(@url)
  else
    { :url => @url,
      :salary => job_salary,
      :title => job_title,
      :apply => apply_link,
      :salary_string => job_salary_string,
      :location => job_location,
      :deadline => deadline,
      :postcode => job_postcode
    }
  end
end