6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
|
# File 'lib/namesies/twitter.rb', line 6
def self.search(query)
reporter = Namesies::Reporter.new('Twitter')
if query.match(/\s/)
reporter.result "Can't search Twitter for usernames with spaces"
return
end
response = Net::HTTP.get_response(URI("https://twitter.com/#{query}"))
case response.code
when "404"
reporter.result "@#{query} available", 'green'
when "200"
reporter.result "@#{query} unavailable", 'red'
else
reporter.result "something's wrong with twitter :("
end
end
|