Mirror of metasploit
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

opt_enum.rb 705B

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748
  1. # -*- coding: binary -*-
  2. module Msf
  3. ###
  4. #
  5. # Enum option.
  6. #
  7. ###
  8. class OptEnum < OptBase
  9. def type
  10. return 'enum'
  11. end
  12. def valid?(value=self.value, check_empty: true)
  13. return false if check_empty && empty_required_value?(value)
  14. return true if value.nil? and !required?
  15. (value and self.enums.include?(value.to_s))
  16. end
  17. def normalize(value=self.value)
  18. return nil if not self.valid?(value)
  19. return value.to_s
  20. end
  21. def desc=(value)
  22. self.desc_string = value
  23. self.desc
  24. end
  25. def desc
  26. if self.enums
  27. str = self.enums.join(', ')
  28. end
  29. "#{self.desc_string || ''} (Accepted: #{str})"
  30. end
  31. protected
  32. attr_accessor :desc_string # :nodoc:
  33. end
  34. end