Class: Internet

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

Constant Summary collapse

@@available =
true

Class Method Summary collapse

Class Method Details

.available?Boolean

Returns:

  • (Boolean)


9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
# File 'lib/base/internet.rb', line 9

def self.available?
	return @@available if !@@available.nil?

	begin
		index=open('http://www.google.com').read 
		if index.include?('<Title>Google')
			@@available = true
		else
			puts "open('http://www.google.com') returned false"
		end
	rescue Exception => e
		puts "open('http://www.google.com') raised an exception: #{e.to_s}"
		@@available = false
	end
	@@available
end