Class: Service
- Inherits:
-
Object
- Object
- Service
- Defined in:
- lib/service.rb
Instance Attribute Summary collapse
-
#monitor ⇒ Object
Returns the value of attribute monitor.
-
#name ⇒ Object
Returns the value of attribute name.
-
#port ⇒ Object
Returns the value of attribute port.
-
#protocol ⇒ Object
readonly
Returns the value of attribute protocol.
-
#severity ⇒ Object
Returns the value of attribute severity.
Instance Method Summary collapse
-
#initialize(proto, p, n = "?", s = 1, sev = 0) ⇒ Service
constructor
A new instance of Service.
- #monitored? ⇒ Boolean
- #set_protocol(str) ⇒ Object
- #switch_state ⇒ Object
Constructor Details
#initialize(proto, p, n = "?", s = 1, sev = 0) ⇒ Service
Returns a new instance of Service.
5 6 7 8 9 10 11 12 13 14 15 |
# File 'lib/service.rb', line 5 def initialize (proto, p, n="?", s=1, sev=0) @protocol=proto @port=p @name=n if (s==1) || (s==true) @monitor=1 else @monitor=0 end @severity = sev end |
Instance Attribute Details
#monitor ⇒ Object
Returns the value of attribute monitor.
3 4 5 |
# File 'lib/service.rb', line 3 def monitor @monitor end |
#name ⇒ Object
Returns the value of attribute name.
3 4 5 |
# File 'lib/service.rb', line 3 def name @name end |
#port ⇒ Object
Returns the value of attribute port.
3 4 5 |
# File 'lib/service.rb', line 3 def port @port end |
#protocol ⇒ Object (readonly)
Returns the value of attribute protocol.
2 3 4 |
# File 'lib/service.rb', line 2 def protocol @protocol end |
#severity ⇒ Object
Returns the value of attribute severity.
3 4 5 |
# File 'lib/service.rb', line 3 def severity @severity end |
Instance Method Details
#monitored? ⇒ Boolean
32 33 34 |
# File 'lib/service.rb', line 32 def monitored?() return @monitor==1 end |
#set_protocol(str) ⇒ Object
17 18 19 20 21 22 23 24 25 26 |
# File 'lib/service.rb', line 17 def set_protocol(str) case str.downcase() when "tcp" @protocol="tcp" when "udp" @protocol="udp" else puts "error setting protocol" end end |
#switch_state ⇒ Object
28 29 30 |
# File 'lib/service.rb', line 28 def switch_state() @state ^=1 end |