Guest User

Untitled

a guest
Jun 23rd, 2018
82
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.41 KB | None | 0 0
  1. #!/usr/bin/ruby
  2.  
  3. module IcmpPoller
  4. def poll
  5. puts "ICMP Polling #{@id}"
  6. end
  7. end
  8.  
  9. module SnmpPoller
  10. def poll
  11. puts "SNMP Polling #{@id}"
  12. end
  13. end
  14.  
  15. class Device
  16. def initialize
  17. @id = 5
  18. end
  19.  
  20. def poll
  21. [IcmpPoller, SnmpPoller].each do |poller|
  22. puts "Running #{poller}"
  23. poller.instance_method(:poll).bind(self).call
  24. end
  25. end
  26. end
  27.  
  28. d = Device.new
  29. d.poll
Add Comment
Please, Sign In to add comment