Class: Msf::OptEnum
Overview
Enum option.
Instance Attribute Summary collapse
-
#desc_string ⇒ Object
protected
:nodoc:.
Attributes inherited from OptBase
#advanced, #aliases, #conditions, #default, #enums, #evasion, #fallbacks, #max_length, #name, #owner, #regex, #required
Instance Method Summary collapse
- #desc ⇒ Object
- #desc=(value) ⇒ Object
-
#initialize(in_name, attrs = [], required: true, **kwargs) ⇒ OptEnum
constructor
This overrides required default from ‘false’ to ‘true’.
- #normalize(value = self.value) ⇒ Object
- #type ⇒ Object
- #valid?(value = self.value, check_empty: true) ⇒ Boolean
Methods inherited from OptBase
#advanced?, #display_value, #empty_required_value?, #evasion?, #invalid_value_length?, #required?, #type?, #validate_on_assignment?
Constructor Details
#initialize(in_name, attrs = [], required: true, **kwargs) ⇒ OptEnum
This overrides required default from ‘false’ to ‘true’
15 16 17 18 |
# File 'lib/msf/core/opt_enum.rb', line 15 def initialize(in_name, attrs = [], required: true, **kwargs) super end |
Instance Attribute Details
#desc_string ⇒ Object (protected)
:nodoc:
47 48 49 |
# File 'lib/msf/core/opt_enum.rb', line 47 def desc_string @desc_string end |
Instance Method Details
#desc ⇒ Object
40 41 42 43 |
# File 'lib/msf/core/opt_enum.rb', line 40 def desc str = enums.join(', ') if enums "#{desc_string || ''} (Accepted: #{str})" end |
#desc=(value) ⇒ Object
35 36 37 38 |
# File 'lib/msf/core/opt_enum.rb', line 35 def desc=(value) self.desc_string = value desc end |
#normalize(value = self.value) ⇒ Object
27 28 29 30 31 32 33 |
# File 'lib/msf/core/opt_enum.rb', line 27 def normalize(value = self.value) if valid?(value) value.to_s else nil end end |
#type ⇒ Object
10 11 12 |
# File 'lib/msf/core/opt_enum.rb', line 10 def type return 'enum' end |
#valid?(value = self.value, check_empty: true) ⇒ Boolean
20 21 22 23 24 25 |
# File 'lib/msf/core/opt_enum.rb', line 20 def valid?(value = self.value, check_empty: true) return false if check_empty && empty_required_value?(value) return true if value.nil? && !required? !value.nil? && enums.include?(value.to_s) end |