Class: Msf::OptBool

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

Overview

Boolean option.

Constant Summary collapse

TrueRegex =
/^(y|yes|t|1|true)$/i

Instance Attribute Summary

Attributes inherited from OptBase

#advanced, #default, #desc, #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

#is_false?(value) ⇒ Boolean


247
248
249
# File 'lib/msf/core/option_container.rb', line 247

def is_false?(value)
  return !is_true?(value)
end

#is_true?(value) ⇒ Boolean


243
244
245
# File 'lib/msf/core/option_container.rb', line 243

def is_true?(value)
  return normalize(value)
end

#normalize(value) ⇒ Object


235
236
237
238
239
240
241
# File 'lib/msf/core/option_container.rb', line 235

def normalize(value)
  if(value.nil? or value.to_s.match(TrueRegex).nil?)
    false
  else
    true
  end
end

#typeObject


219
220
221
# File 'lib/msf/core/option_container.rb', line 219

def type
  return 'bool'
end

#valid?(value) ⇒ Boolean


223
224
225
226
227
228
229
230
231
232
233
# File 'lib/msf/core/option_container.rb', line 223

def valid?(value)
  return false if empty_required_value?(value)

  if ((value != nil and
      (value.to_s.empty? == false) and
      (value.to_s.match(/^(y|yes|n|no|t|f|0|1|true|false)$/i) == nil)))
    return false
  end

  true
end