Class: Msf::OptFloat

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

Overview

Float option.

Instance Attribute Summary

Attributes inherited from OptBase

#advanced, #aliases, #conditions, #default, #desc, #enums, #evasion, #fallbacks, #max_length, #name, #owner, #regex, #required

Instance Method Summary collapse

Methods inherited from OptBase

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

Constructor Details

This class inherits a constructor from Msf::OptBase

Instance Method Details

#normalize(value) ⇒ Object



14
15
16
# File 'lib/msf/core/opt_float.rb', line 14

def normalize(value)
  Float(value) if value.present? && valid?(value)
end

#typeObject



10
11
12
# File 'lib/msf/core/opt_float.rb', line 10

def type
  'float'
end

#valid?(value, check_empty: true) ⇒ Boolean

Returns:

  • (Boolean)


18
19
20
21
22
# File 'lib/msf/core/opt_float.rb', line 18

def valid?(value, check_empty: true)
  return false if check_empty && empty_required_value?(value)
  Float(value) rescue return false if value.present?
  super
end