class Simplyhired::Client

Attributes

city[R]
current_page[R]
days[R]
distance[R]
error[R]
jobs[R]
keywords[R]
location[R]
page_size[R]
query_type[R]
state[R]
zip[R]

Public Class Methods

new(ip) click to toggle source
# File lib/simplyhired/client.rb, line 8
def initialize(ip)
        config_values = Simplyhired.config_values
        @pshid = config_values[:pshid]
        @jbd = config_values[:jbd]
        @credentials = "?pshid=#{@pshid}&ssty=2&cflg=r&jbd=#{@jbd}&clip=#{ip}"
end

Public Instance Methods

next() click to toggle source
# File lib/simplyhired/client.rb, line 42
def next
        if @current_page * @page_size < @accessible_count.to_i
                @current_page += 1
                search @current_page
        else
                @jobs = nil
        end
        @jobs
end
search_jobs(kw, z, c, s, options = {}) click to toggle source
# File lib/simplyhired/client.rb, line 15
def search_jobs(kw, z, c, s, options = {})
        unless @pshid
                @error = 'define pshid in a configuration file'
                return nil
        end
        unless @jbd
                @error = 'define jbd in a configuration file'
                return nil
        end
        @query_type = options[:query_type] || :OR
        @zip = z
        @city = c && c.split.join('+')
        @state = s && s.split.join('+')
        @page_size = options[:ws] || 25
        @distance = options[:distance] || 10
        @days = options[:days] || 0

        @keywords = kw

        @location = (@zip && !@zip.empty?) ? @zip : "#{@city},#{@state}"
        @current_page = options[:page] || 1

        @uri = ""
        @jobs = nil
        search @current_page
        @jobs
end
total_jobs_found() click to toggle source
# File lib/simplyhired/client.rb, line 51
def total_jobs_found
        @accessible_count || 0
end

Private Instance Methods