Class: Arachni::Component::Options::Int

Inherits:
Base show all
Defined in:
lib/arachni/component/options/int.rb

Overview

Integer option.

Instance Attribute Summary

Attributes inherited from Base

#default, #desc, #enums, #name

Instance Method Summary collapse

Methods inherited from Base

#==, #empty_required_value?, #initialize, #required?, #to_h, #type?

Constructor Details

This class inherits a constructor from Arachni::Component::Options::Base

Instance Method Details

#normalize(value) ⇒ Object



27
28
29
30
31
32
33
# File 'lib/arachni/component/options/int.rb', line 27

def normalize( value )
    if value.to_s.match( /^0x[a-fA-F\d]+$/ )
        value.to_i( 16 )
    elsif value.to_s.match( /^\d+$/ )
        value.to_i
    end
end

#typeObject



23
24
25
# File 'lib/arachni/component/options/int.rb', line 23

def type
    'integer'
end

#valid?(value) ⇒ Boolean

Returns:

  • (Boolean)


35
36
37
38
39
40
41
42
43
# File 'lib/arachni/component/options/int.rb', line 35

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

    if value && !normalize( value ).to_s.match( /^\d+$/ )
        return false
    end

    super
end