Sha256: 0fb0ec10b5136a6cc7c27cbd7c4a1e677f0632f15525873cdefc2cfd4e5e5501

Contents?: true

Size: 870 Bytes

Versions: 7

Compression:

Stored size: 870 Bytes

Contents

=begin
    Copyright 2010-2014 Tasos Laskos <tasos.laskos@arachni-scanner.com>

    This file is part of the Arachni Framework project and is subject to
    redistribution and commercial restrictions. Please see the Arachni Framework
    web site for more information on licensing and terms of use.
=end

# Boolean option.
#
# @author Tasos "Zapotek" Laskos <tasos.laskos@arachni-scanner.com>
class Arachni::Component::Options::Bool < Arachni::Component::Options::Base

    TRUE_REGEX   = /^(y|yes|t|1|true|on)$/i
    VALID_REGEXP = /^(y|yes|n|no|t|f|0|1|true|false|on)$/i

    def valid?
        return false if !super
        effective_value.to_s.match( VALID_REGEXP )
    end

    def normalize
        effective_value.to_s =~ TRUE_REGEX
    end

    def true?
        normalize
    end

    def false?
        !true?
    end

    def type
        :bool
    end

end

Version data entries

7 entries across 7 versions & 1 rubygems

Version Path
arachni-1.0.6 lib/arachni/component/options/bool.rb
arachni-1.0.5 lib/arachni/component/options/bool.rb
arachni-1.0.4 lib/arachni/component/options/bool.rb
arachni-1.0.3 lib/arachni/component/options/bool.rb
arachni-1.0.2 lib/arachni/component/options/bool.rb
arachni-1.0.1 lib/arachni/component/options/bool.rb
arachni-1.0 lib/arachni/component/options/bool.rb