Class: LgPodPlugin::Ping
- Inherits:
-
Object
- Object
- LgPodPlugin::Ping
- Defined in:
- lib/lg_pod_plugin/net-ping.rb
Instance Attribute Summary collapse
-
#ip ⇒ Object
Returns the value of attribute ip.
-
#network_ok ⇒ Object
Returns the value of attribute network_ok.
-
#uri ⇒ Object
Returns the value of attribute uri.
Instance Method Summary collapse
-
#initialize(url) ⇒ Ping
constructor
A new instance of Ping.
- #ping ⇒ Object
Constructor Details
#initialize(url) ⇒ Ping
Returns a new instance of Ping.
12 13 14 |
# File 'lib/lg_pod_plugin/net-ping.rb', line 12 def initialize(url) self.uri = LUtils.git_to_uri(url) end |
Instance Attribute Details
#ip ⇒ Object
Returns the value of attribute ip.
10 11 12 |
# File 'lib/lg_pod_plugin/net-ping.rb', line 10 def ip @ip end |
#network_ok ⇒ Object
Returns the value of attribute network_ok.
11 12 13 |
# File 'lib/lg_pod_plugin/net-ping.rb', line 11 def network_ok @network_ok end |
#uri ⇒ Object
Returns the value of attribute uri.
9 10 11 |
# File 'lib/lg_pod_plugin/net-ping.rb', line 9 def uri @uri end |
Instance Method Details
#ping ⇒ Object
16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 |
# File 'lib/lg_pod_plugin/net-ping.rb', line 16 def ping return false unless self.uri result = %x(ping #{uri.host} -t 1) if result.include?("timeout") return false end if result && result.include?("(") && result.include?("):") ip_address = result.split("(").last.split(")").first begin if IPAddr.new ip_address self.ip = ip_address return true else return false end rescue return false end else return false end end |