Module: Bowline::Desktop::Network

Extended by:
Network, Watcher::Base
Included in:
Network
Defined in:
lib/bowline/desktop/network.rb

Instance Method Summary collapse

Methods included from Watcher::Base

extended, included, watcher

Instance Method Details

#hostObject



28
29
30
# File 'lib/bowline/desktop/network.rb', line 28

def host
  @host ||= "google.com"
end

#host=(host) ⇒ Object



32
33
34
# File 'lib/bowline/desktop/network.rb', line 32

def host=(host)
  @host = host
end

#offline!Object



17
18
19
20
21
22
# File 'lib/bowline/desktop/network.rb', line 17

def offline!
  return if @online == false
  @online = false
  watcher.call(:on_offline)
  watcher.call(:on_change)
end

#online!Object



10
11
12
13
14
15
# File 'lib/bowline/desktop/network.rb', line 10

def online!
  return if @online
  @online = true
  watcher.call(:on_online)
  watcher.call(:on_change)
end

#online?Boolean

Returns:

  • (Boolean)


24
25
26
# File 'lib/bowline/desktop/network.rb', line 24

def online?
  @online
end

#poll!Object



44
45
46
47
48
49
50
51
# File 'lib/bowline/desktop/network.rb', line 44

def poll!
  Thread.new do
    loop do
      ping ? online! : offline!
      sleep 30
    end
  end
end

#portObject



36
37
38
# File 'lib/bowline/desktop/network.rb', line 36

def port
  @port ||= 80
end

#port=(port) ⇒ Object



40
41
42
# File 'lib/bowline/desktop/network.rb', line 40

def port=(port)
  @port = port
end