class EyePea::Client

Public Class Methods

error_msg() click to toggle source

Error when can’t find ip

# File lib/eyepea/client.rb, line 35
def self.error_msg
  msgs = [
    'Uh oh! Some unknown error occurred'
  ]
  msgs[rand(msgs.size)]
end
get_ip() click to toggle source

Make api request to get IP

# File lib/eyepea/client.rb, line 23
def self.get_ip
  result = Net::HTTP.get(URI.parse(@@API+'/ip.json'))
  json_result = JSON.parse(result)

  if json_result.has_key? 'Error'
    raise 'JSON error'
  end

  json_result['ip'].to_s
end
loading_msg() click to toggle source

Text loading

# File lib/eyepea/client.rb, line 47
def self.loading_msg
  msgs = [
    'Body massage machine go',
    'Searching the intertubes',
    'Dialing up',
    'Here we go'
  ]
  msgs[rand(msgs.size)] + '..'
end
run!() click to toggle source

Run her baby

# File lib/eyepea/client.rb, line 11
def self.run!
  puts self.loading_msg
  begin
    ip = self.get_ip
    puts self.success_msg(ip)
  rescue Exception => e
    puts e if @@DEBUG
    puts self.error_msg
  end
end
success_msg(ip) click to toggle source
# File lib/eyepea/client.rb, line 42
def self.success_msg(ip)
  "IP: "+ip.to_s
end