Class: BaseApiClient
- Inherits:
-
Base
- Object
- Base
- BaseApiClient
show all
- Defined in:
- lib/whos_using_what/api_clients/base_api_client.rb
Instance Attribute Summary
Attributes inherited from Base
#set_paths
Class Method Summary
collapse
Instance Method Summary
collapse
Methods inherited from Base
set_paths
Class Method Details
.arraySearch(array, rawHtml) ⇒ Object
11
12
13
14
15
16
17
18
19
20
|
# File 'lib/whos_using_what/api_clients/base_api_client.rb', line 11
def self.arraySearch(array, rawHtml)
rawHtml = rawHtml.downcase
array.each do |token|
if (rawHtml.index(token) != nil)
return true
end
end
return false
end
|
.arry_to_str_delim(array, delim) ⇒ Object
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
|
# File 'lib/whos_using_what/api_clients/base_api_client.rb', line 23
def self.arry_to_str_delim array, delim
str = ""
i = 0
array.each do |entry|
if i < 1
str = entry.strip
else
str = str << delim << entry.strip
end
i += 1
end
str.strip
end
|
.cleanup_url(url) ⇒ Object
41
42
43
44
45
46
47
48
49
50
51
52
|
# File 'lib/whos_using_what/api_clients/base_api_client.rb', line 41
def self.cleanup_url url
url = url.strip
if url["www."] != nil
url["www."] = ""
end
if url["site:"] != nil
url["site:"] = ""
end
url
end
|
.prepare_params_from_map_helper(base_url, params_map) ⇒ Object
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
|
# File 'lib/whos_using_what/api_clients/base_api_client.rb', line 69
def self.prepare_params_from_map_helper (base_url, params_map)
iter = 1
base_url = base_url << "?"
params_map.each do |key, value|
if iter != 1
base_url = base_url << "&"
end
if starts_with?(key, "facet")
base_url = base_url << key << "," << value
else
base_url = base_url << key << "=" << value
end
iter = iter + 1
end
base_url
end
|
.starts_with?(string, prefix) ⇒ Boolean
63
64
65
66
|
# File 'lib/whos_using_what/api_clients/base_api_client.rb', line 63
def self.starts_with?(string, prefix)
prefix = prefix.to_s
string[0, prefix.length] == prefix
end
|
Instance Method Details
#determineIfUsesTechnology(technology, rawHtml) ⇒ Object
54
55
56
57
58
59
60
|
# File 'lib/whos_using_what/api_clients/base_api_client.rb', line 54
def determineIfUsesTechnology(technology, rawHtml)
isJobPage = BaseApiClient.arraySearch(@jobPageTokens, rawHtml)
return isJobPage
end
|