Class: Simplyhired::Client
- Inherits:
-
Object
- Object
- Simplyhired::Client
- Defined in:
- lib/simplyhired/client.rb
Defined Under Namespace
Classes: Handler
Instance Attribute Summary collapse
-
#city ⇒ Object
readonly
Returns the value of attribute city.
-
#current_page ⇒ Object
readonly
Returns the value of attribute current_page.
-
#days ⇒ Object
readonly
Returns the value of attribute days.
-
#distance ⇒ Object
readonly
Returns the value of attribute distance.
-
#error ⇒ Object
readonly
Returns the value of attribute error.
-
#jobs ⇒ Object
readonly
Returns the value of attribute jobs.
-
#keywords ⇒ Object
readonly
Returns the value of attribute keywords.
-
#location ⇒ Object
readonly
Returns the value of attribute location.
-
#page_size ⇒ Object
readonly
Returns the value of attribute page_size.
-
#query_type ⇒ Object
readonly
Returns the value of attribute query_type.
-
#state ⇒ Object
readonly
Returns the value of attribute state.
-
#zip ⇒ Object
readonly
Returns the value of attribute zip.
Instance Method Summary collapse
-
#initialize(ip) ⇒ Client
constructor
A new instance of Client.
- #next ⇒ Object
- #search_jobs(kw, z, c, s, options = {}) ⇒ Object
- #total_jobs_found ⇒ Object
Constructor Details
#initialize(ip) ⇒ Client
Returns a new instance of Client.
8 9 10 11 12 13 |
# 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 |
Instance Attribute Details
#city ⇒ Object (readonly)
Returns the value of attribute city.
6 7 8 |
# File 'lib/simplyhired/client.rb', line 6 def city @city end |
#current_page ⇒ Object (readonly)
Returns the value of attribute current_page.
6 7 8 |
# File 'lib/simplyhired/client.rb', line 6 def current_page @current_page end |
#days ⇒ Object (readonly)
Returns the value of attribute days.
6 7 8 |
# File 'lib/simplyhired/client.rb', line 6 def days @days end |
#distance ⇒ Object (readonly)
Returns the value of attribute distance.
6 7 8 |
# File 'lib/simplyhired/client.rb', line 6 def distance @distance end |
#error ⇒ Object (readonly)
Returns the value of attribute error.
6 7 8 |
# File 'lib/simplyhired/client.rb', line 6 def error @error end |
#jobs ⇒ Object (readonly)
Returns the value of attribute jobs.
6 7 8 |
# File 'lib/simplyhired/client.rb', line 6 def jobs @jobs end |
#keywords ⇒ Object (readonly)
Returns the value of attribute keywords.
6 7 8 |
# File 'lib/simplyhired/client.rb', line 6 def keywords @keywords end |
#location ⇒ Object (readonly)
Returns the value of attribute location.
6 7 8 |
# File 'lib/simplyhired/client.rb', line 6 def location @location end |
#page_size ⇒ Object (readonly)
Returns the value of attribute page_size.
6 7 8 |
# File 'lib/simplyhired/client.rb', line 6 def page_size @page_size end |
#query_type ⇒ Object (readonly)
Returns the value of attribute query_type.
6 7 8 |
# File 'lib/simplyhired/client.rb', line 6 def query_type @query_type end |
#state ⇒ Object (readonly)
Returns the value of attribute state.
6 7 8 |
# File 'lib/simplyhired/client.rb', line 6 def state @state end |
#zip ⇒ Object (readonly)
Returns the value of attribute zip.
6 7 8 |
# File 'lib/simplyhired/client.rb', line 6 def zip @zip end |
Instance Method Details
#next ⇒ Object
42 43 44 45 46 47 48 49 50 |
# 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 = {}) ⇒ Object
15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 |
# File 'lib/simplyhired/client.rb', line 15 def search_jobs(kw, z, c, s, = {}) 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 = [:query_type] || :OR @zip = z @city = c && c.split.join('+') @state = s && s.split.join('+') @page_size = [:ws] || 25 @distance = [:distance] || 10 @days = [:days] || 0 @keywords = kw @location = (@zip && !@zip.empty?) ? @zip : "#{@city},#{@state}" @current_page = [:page] || 1 @uri = "" @jobs = nil search @current_page @jobs end |
#total_jobs_found ⇒ Object
51 52 53 |
# File 'lib/simplyhired/client.rb', line 51 def total_jobs_found @accessible_count || 0 end |