Class: Snort::RuleOption

Inherits:
Object
  • Object
show all
Defined in:
lib/snort/rule/option.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(keyword, arguments = nil) ⇒ RuleOption

Returns a new instance of RuleOption.

Parameters:

  • keyword (String)
  • arguments (String) (defaults to: nil)


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

#argumentsObject (readonly)

Returns the value of attribute arguments.



4
5
6
# File 'lib/snort/rule/option.rb', line 4

def arguments
  @arguments
end

#keywordObject (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

Returns:

  • (Boolean)


34
35
36
# File 'lib/snort/rule/option.rb', line 34

def eql?(other)
  self == other
end

#hashObject



38
39
40
# File 'lib/snort/rule/option.rb', line 38

def hash
  [@keyword, @arguments].hash
end

#to_sObject



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