Class: Msf::OptEnum

Inherits:
OptBase show all
Defined in:
lib/msf/core/option_container.rb

Overview

Enum option.

Instance Attribute Summary

Attributes inherited from OptBase

#advanced, #default, #enums, #evasion, #name, #owner, #required

Instance Method Summary collapse

Methods inherited from OptBase

#advanced?, #display_value, #empty_required_value?, #evasion?, #initialize, #required?, #type?

Constructor Details

This class inherits a constructor from Msf::OptBase

Instance Method Details

#descObject


282
283
284
285
286
287
# File 'lib/msf/core/option_container.rb', line 282

def desc
  if self.enums
    str = self.enums.join(', ')
  end
  "#{self.desc_string || ''} (accepted: #{str})"
end

#desc=(value) ⇒ Object


276
277
278
279
280
# File 'lib/msf/core/option_container.rb', line 276

def desc=(value)
  self.desc_string = value

  self.desc
end

#normalize(value = self.value) ⇒ Object


271
272
273
274
# File 'lib/msf/core/option_container.rb', line 271

def normalize(value=self.value)
  return nil if not self.valid?(value)
  return value.to_s
end

#typeObject


260
261
262
# File 'lib/msf/core/option_container.rb', line 260

def type
  return 'enum'
end

#valid?(value = self.value) ⇒ Boolean


264
265
266
267
268
269
# File 'lib/msf/core/option_container.rb', line 264

def valid?(value=self.value)
  return false if empty_required_value?(value)
  return true if value.nil? and !required?

  (value and self.enums.include?(value.to_s))
end