Class: JobCentral::Employer
- Inherits:
-
Struct
- Object
- Struct
- JobCentral::Employer
- Extended by:
- Helpers
- Includes:
- Helpers
- Defined in:
- lib/job_central.rb
Instance Attribute Summary collapse
-
#date_updated ⇒ Object
Returns the value of attribute date_updated.
-
#name ⇒ Object
Returns the value of attribute name.
Class Method Summary collapse
Instance Method Summary collapse
Methods included from Helpers
Instance Attribute Details
#date_updated ⇒ Object
Returns the value of attribute date_updated
41 42 43 |
# File 'lib/job_central.rb', line 41 def date_updated @date_updated end |
#name ⇒ Object
Returns the value of attribute name
41 42 43 |
# File 'lib/job_central.rb', line 41 def name @name end |
Class Method Details
.all ⇒ Object
48 49 50 |
# File 'lib/job_central.rb', line 48 def all parse(BASE_URI + "/index.asp") end |
.members ⇒ Object
52 53 54 |
# File 'lib/job_central.rb', line 52 def members parse(BASE_URI + "/index.asp?member=member") end |
.parse(uri) ⇒ Object
56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 |
# File 'lib/job_central.rb', line 56 def parse(uri) html = Nokogiri::HTML open(uri) employer_rows = ((html/"table")[-1]/"tr") employer_hash = Hash.new { |h, k| h[k] = Employer.new } employer_rows.each_with_index do |element, idx| next unless idx >= 2 # skip header rows attributes = element/"td" name = attributes[0].text.strip employer = employer_hash[name] employer.name = name employer.date_updated = [employer.date_updated, parse_date(attributes[3].text)].compact.max employer.feeds << BASE_URI + (attributes[1]/"a").attr('href') end employers = employer_hash.values employers.extend Finders employers end |