Class: Vicopo

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

Class Method Summary collapse

Class Method Details

.get(search, protocol = 'https') ⇒ Object


5
6
7
8
9
10
11
12
13
# File 'lib/vicopo.rb', line 5

def self.get(search, protocol = 'https')
	uri = URI(protocol + '://vicopo.selfbuild.fr/search/' + search.to_s)
	response = JSON.parse(Net::HTTP.get(uri))
	if response['cities']
		return response['cities']
	else
		raise 'No valid answear found.'
	end
end

.http(search) ⇒ Object


14
15
16
# File 'lib/vicopo.rb', line 14

def self.http(search)
	return self.get(search, 'http')
end

.https(search) ⇒ Object


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

def self.https(search)
	return self.get(search, 'https')
end