Class: CheckHostIp
- Inherits:
-
Object
- Object
- CheckHostIp
- Defined in:
- lib/check_host/check_host_ip.rb
Instance Attribute Summary collapse
-
#host ⇒ Object
Returns the value of attribute host.
-
#ip ⇒ Object
Returns the value of attribute ip.
Instance Method Summary collapse
-
#cmd ⇒ Object
Runs the host cmd and returns just the A record example: “fawazalhokairfashion.com has address 91.109.13.176n”.
-
#initialize(host, ip) ⇒ CheckHostIp
constructor
A new instance of CheckHostIp.
-
#notify ⇒ Object
Sends an email if result? is true If result? is true then SendMail.
-
#result? ⇒ Boolean
Checks whether a string contains the ip address.
Constructor Details
#initialize(host, ip) ⇒ CheckHostIp
Returns a new instance of CheckHostIp.
7 8 9 10 |
# File 'lib/check_host/check_host_ip.rb', line 7 def initialize(host, ip) @host = host @ip = ip end |
Instance Attribute Details
#host ⇒ Object
Returns the value of attribute host.
5 6 7 |
# File 'lib/check_host/check_host_ip.rb', line 5 def host @host end |
#ip ⇒ Object
Returns the value of attribute ip.
5 6 7 |
# File 'lib/check_host/check_host_ip.rb', line 5 def ip @ip end |
Instance Method Details
#cmd ⇒ Object
Runs the host cmd and returns just the A record example: “fawazalhokairfashion.com has address 91.109.13.176n”
15 16 17 |
# File 'lib/check_host/check_host_ip.rb', line 15 def cmd `host -t A #{host}` end |
#notify ⇒ Object
Sends an email if result? is true If result? is true then SendMail
28 29 30 31 32 33 34 35 |
# File 'lib/check_host/check_host_ip.rb', line 28 def notify if result? SendMail.new true else false end end |
#result? ⇒ Boolean
Checks whether a string contains the ip address
21 22 23 |
# File 'lib/check_host/check_host_ip.rb', line 21 def result? !cmd.include? ip end |