module Careers::Feed
Constants
- FILTERMAP
- URL
Public Class Methods
fetch(filters={})
click to toggle source
Fetches current job listings using supplied filters, if any. Returns a list of Careers::Feed::Entry
objects.
# File lib/careers/feed.rb, line 12 def self.fetch(filters={}) feed(filters).items.collect do |item| Entry.build item end end
Private Class Methods
conn()
click to toggle source
Establishes and returs a connection object.
# File lib/careers/feed.rb, line 21 def self.conn Faraday.new(:url => URL) do |faraday| faraday.adapter :typhoeus end end
feed(filters={})
click to toggle source
Fetches raw feed, parses it, and returns the result.
# File lib/careers/feed.rb, line 28 def self.feed(filters={}) validate_filters!(filters) response = conn.get "", filters raise response.body if response.status != 200 RSS::Parser.parse response.body end
validate_filters!(filters)
click to toggle source
Given a hash, it first removes any keys that are not found in FILTERMAP
. Then, replaces any keys that have a match in FILTERMAP
.
The service endpoint expects params that seem to have no standard format, and do not follow any sort of Ruby style. So, the point of the replacement is to provide to the user of this gem params styled in a format they would be familiar with.
See Careers::Feed::FILTERMAP
for available filters.
# File lib/careers/feed.rb, line 44 def self.validate_filters!(filters) filters.keep_if { |k, v| FILTERMAP.key? k } filters.keys.each { |k| filters[ FILTERMAP[k] ] = filters.delete(k) } end