Module: Bowline::Desktop::Network
Instance Method Summary
collapse
extended, included, watcher
Instance Method Details
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
|
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
|
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
24
25
26
|
# File 'lib/bowline/desktop/network.rb', line 24
def online?
@online
end
|
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
|
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
|