Class: Arachni::Component::Options::MultipleChoice

Inherits:
Base
  • Object
show all
Defined in:
lib/arachni/component/options/multiple_choice.rb

Overview

MultipleChoice option.

Author:

Instance Attribute Summary collapse

Attributes inherited from Base

#default, #name, #value

Instance Method Summary collapse

Methods inherited from Base

#==, #effective_value, #for_component, from_rpc_data, #hash, #missing_value?, #required?, #to_h, #to_rpc_data

Constructor Details

#initialize(name, options = {}) ⇒ MultipleChoice

Returns a new instance of MultipleChoice.


17
18
19
20
21
# File 'lib/arachni/component/options/multiple_choice.rb', line 17

def initialize( name, options = {} )
    options  = options.dup
    @choices = [options.delete(:choices)].flatten.compact.map(&:to_s)
    super
end

Instance Attribute Details

#choicesObject

The list of potential valid values


15
16
17
# File 'lib/arachni/component/options/multiple_choice.rb', line 15

def choices
  @choices
end

Instance Method Details

#descriptionObject


32
33
34
# File 'lib/arachni/component/options/multiple_choice.rb', line 32

def description
    "#{@description} (accepted: #{choices.join( ', ' )})"
end

#normalizeObject


23
24
25
# File 'lib/arachni/component/options/multiple_choice.rb', line 23

def normalize
    super.to_s
end

#typeObject


36
37
38
# File 'lib/arachni/component/options/multiple_choice.rb', line 36

def type
    :multiple_choice
end

#valid?Boolean

Returns:

  • (Boolean)

27
28
29
30
# File 'lib/arachni/component/options/multiple_choice.rb', line 27

def valid?
    return false if !super
    choices.include?( effective_value )
end