Class: Snort::RuleOption
- Inherits:
-
Object
- Object
- Snort::RuleOption
- Defined in:
- lib/snort/rule/option.rb
Instance Attribute Summary collapse
-
#arguments ⇒ Object
readonly
Returns the value of attribute arguments.
-
#keyword ⇒ Object
readonly
Returns the value of attribute keyword.
Instance Method Summary collapse
- #==(other) ⇒ Object
- #add_argument(argument) ⇒ Object
- #eql?(other) ⇒ Boolean
- #hash ⇒ Object
-
#initialize(keyword, arguments = nil) ⇒ RuleOption
constructor
A new instance of RuleOption.
- #to_s ⇒ Object
Constructor Details
#initialize(keyword, arguments = nil) ⇒ RuleOption
Returns a new instance of RuleOption.
8 9 10 11 12 13 14 15 16 17 18 19 |
# File 'lib/snort/rule/option.rb', line 8 def initialize(keyword, arguments=nil) @keyword = keyword.to_s if arguments == nil @arguments = [] elsif arguments.class == String or arguments.class == Fixnum @arguments = [arguments] elsif arguments.class == Array @arguments = arguments else raise "I don't know what to do with an argument of class #{arguments.class}" end end |
Instance Attribute Details
#arguments ⇒ Object (readonly)
Returns the value of attribute arguments.
4 5 6 |
# File 'lib/snort/rule/option.rb', line 4 def arguments @arguments end |
#keyword ⇒ Object (readonly)
Returns the value of attribute keyword.
4 5 6 |
# File 'lib/snort/rule/option.rb', line 4 def keyword @keyword end |
Instance Method Details
#==(other) ⇒ Object
30 31 32 |
# File 'lib/snort/rule/option.rb', line 30 def ==(other) @keyword == other.keyword && @arguments == other.arguments end |
#add_argument(argument) ⇒ Object
21 22 23 |
# File 'lib/snort/rule/option.rb', line 21 def add_argument(argument) @arguments << argument end |
#eql?(other) ⇒ Boolean
34 35 36 |
# File 'lib/snort/rule/option.rb', line 34 def eql?(other) self == other end |
#hash ⇒ Object
38 39 40 |
# File 'lib/snort/rule/option.rb', line 38 def hash [@keyword, @arguments].hash end |
#to_s ⇒ Object
25 26 27 28 |
# File 'lib/snort/rule/option.rb', line 25 def to_s return "#{@keyword};" if @arguments.length == 0 "#{@keyword}:#{@arguments.join("; ")};" end |