Class: JobCentral::Job
- Inherits:
-
Struct
- Object
- Struct
- JobCentral::Job
- Extended by:
- Helpers
- Includes:
- Helpers
- Defined in:
- lib/job_central.rb
Instance Attribute Summary collapse
-
#city ⇒ Object
Returns the value of attribute city.
-
#country ⇒ Object
Returns the value of attribute country.
-
#description ⇒ Object
Returns the value of attribute description.
-
#employer_name ⇒ Object
Returns the value of attribute employer_name.
-
#expiration_date ⇒ Object
Returns the value of attribute expiration_date.
-
#guid ⇒ Object
Returns the value of attribute guid.
-
#imagelink ⇒ Object
Returns the value of attribute imagelink.
-
#industries ⇒ Object
Returns the value of attribute industries.
-
#link ⇒ Object
Returns the value of attribute link.
-
#location ⇒ Object
Returns the value of attribute location.
-
#state ⇒ Object
Returns the value of attribute state.
-
#title ⇒ Object
Returns the value of attribute title.
-
#zip_code ⇒ Object
Returns the value of attribute zip_code.
Class Method Summary collapse
Methods included from Helpers
Instance Attribute Details
#city ⇒ Object
Returns the value of attribute city
99 100 101 |
# File 'lib/job_central.rb', line 99 def city @city end |
#country ⇒ Object
Returns the value of attribute country
99 100 101 |
# File 'lib/job_central.rb', line 99 def country @country end |
#description ⇒ Object
Returns the value of attribute description
99 100 101 |
# File 'lib/job_central.rb', line 99 def description @description end |
#employer_name ⇒ Object
Returns the value of attribute employer_name
99 100 101 |
# File 'lib/job_central.rb', line 99 def employer_name @employer_name end |
#expiration_date ⇒ Object
Returns the value of attribute expiration_date
99 100 101 |
# File 'lib/job_central.rb', line 99 def expiration_date @expiration_date end |
#guid ⇒ Object
Returns the value of attribute guid
99 100 101 |
# File 'lib/job_central.rb', line 99 def guid @guid end |
#imagelink ⇒ Object
Returns the value of attribute imagelink
99 100 101 |
# File 'lib/job_central.rb', line 99 def imagelink @imagelink end |
#industries ⇒ Object
Returns the value of attribute industries
99 100 101 |
# File 'lib/job_central.rb', line 99 def industries @industries end |
#link ⇒ Object
Returns the value of attribute link
99 100 101 |
# File 'lib/job_central.rb', line 99 def link @link end |
#location ⇒ Object
Returns the value of attribute location
99 100 101 |
# File 'lib/job_central.rb', line 99 def location @location end |
#state ⇒ Object
Returns the value of attribute state
99 100 101 |
# File 'lib/job_central.rb', line 99 def state @state end |
#title ⇒ Object
Returns the value of attribute title
99 100 101 |
# File 'lib/job_central.rb', line 99 def title @title end |
#zip_code ⇒ Object
Returns the value of attribute zip_code
99 100 101 |
# File 'lib/job_central.rb', line 99 def zip_code @zip_code end |
Class Method Details
.extract_location(element) ⇒ Object
138 139 140 141 |
# File 'lib/job_central.rb', line 138 def self.extract_location(element) location = extract_text(element, "location") location.gsub(/^\,\s+/, '') end |
.extract_text(element, tag) ⇒ Object
133 134 135 136 |
# File 'lib/job_central.rb', line 133 def self.extract_text(element, tag) element = element.at(tag) element && element.text end |
.from_xml(uri) ⇒ Object
106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 |
# File 'lib/job_central.rb', line 106 def self.from_xml(uri) xml = Nokogiri::XML open(uri) jobs = [] (xml/"job").each do |element| location = extract_location(element) parsed_location = LocationParser.parse(location) job = Job.new job.guid = extract_text(element, "guid") job.title = extract_text(element, "title") job.description = extract_text(element, "description") job.link = extract_text(element, "link") job.imagelink = extract_text(element, "imagelink") job.expiration_date = Date.parse(extract_text(element, "expiration_date")) job.employer_name = extract_text(element, "employer") job.location = location job.city = parsed_location[:city] job.state = parsed_location[:state] job.zip_code = parsed_location[:zip_code] job.country = parsed_location[:country] element.css("industry").each do |industry| job.industries << industry.text end jobs << job end jobs end |