Class: Indeed

Inherits:
Object
  • Object
show all
Defined in:
lib/indeed.rb

Constant Summary collapse

SEARCH_URL =
URI.parse("http://api.indeed.com/ads/apisearch")
GET_URL =
URI.parse("http://api.indeed.com/ads/apigetjobs")

Class Method Summary collapse

Instance Method Summary collapse

Class Method Details

.default_paramsObject



25
26
27
# File 'lib/indeed.rb', line 25

def self.default_params
  self.instance.default_params
end

.get(*job_keys) ⇒ Object



29
30
31
# File 'lib/indeed.rb', line 29

def self.get(*job_keys)
  self.instance.get(*job_keys)
end

.instanceObject



13
14
15
# File 'lib/indeed.rb', line 13

def self.instance
  @instance ||= Indeed.new
end

.key=(key) ⇒ Object



21
22
23
# File 'lib/indeed.rb', line 21

def self.key=(key)
  self.default_params[:publisher] = key
end

.search(options) ⇒ Object



17
18
19
# File 'lib/indeed.rb', line 17

def self.search(options)
  self.instance.search(options)
end

Instance Method Details

#default_paramsObject



50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
# File 'lib/indeed.rb', line 50

def default_params
  @default_params ||= {
    :v => 2,
    :format => "json",
    :sort => "relevance",
    :radius => 25,
    :st => nil,
    :jt => nil,
    :limit => 30,
    :highlight => 0,
    :filter => 1,
    :fromage => 1,
    :latlong => 1,
    :co => "us",
    :userip => "77.88.216.22",
    :useragent => "Mozilla/4.0 Firefox",
  }
end

#get(jobkeys) ⇒ Object



38
39
40
41
42
43
44
45
46
47
48
# File 'lib/indeed.rb', line 38

def get(jobkeys)
  jobkeys = Array(jobkeys)
  http_get(
    GET_URL.host,
    GET_URL.path,
    :jobkeys => jobkeys,
    :v => 2,
    :publisher => default_params[:publisher],
    :format => "json"
  )
end

#search(options) ⇒ Object



33
34
35
36
# File 'lib/indeed.rb', line 33

def search(options)
  options = default_params.merge(options)
  http_get(SEARCH_URL.host, SEARCH_URL.path, options)
end