Class: Internet

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

Constant Summary collapse

@@available =
true

Class Method Summary collapse

Class Method Details

.available?Boolean

Returns:

  • (Boolean)


717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
# File 'lib/dev_commands.rb', line 717

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