metasploit-framework/lib/msf/core/opt_enum.rb

49 lines
705 B
Ruby
Raw Normal View History

# -*- coding: binary -*-
module Msf
###
#
# Enum option.
#
###
class OptEnum < OptBase
def type
return 'enum'
end
2016-05-23 19:56:19 +00:00
def valid?(value=self.value, check_empty: true)
return false if check_empty && empty_required_value?(value)
return true if value.nil? and !required?
(value and self.enums.include?(value.to_s))
end
def normalize(value=self.value)
return nil if not self.valid?(value)
return value.to_s
end
def desc=(value)
self.desc_string = value
self.desc
end
def desc
if self.enums
str = self.enums.join(', ')
end
2015-06-16 10:52:42 +00:00
"#{self.desc_string || ''} (Accepted: #{str})"
end
protected
attr_accessor :desc_string # :nodoc:
end
end