Class: Nikto::Command::PortList

Inherits:
CommandMapper::Types::Num
  • Object
show all
Defined in:
lib/nikto/command.rb

Instance Method Summary collapse

Instance Method Details

#format(value) ⇒ Object



93
94
95
96
97
98
99
100
101
102
# File 'lib/nikto/command.rb', line 93

def format(value)
  case value
  when Array
    value.map(&method(:format)).join(',')
  when Range
    "#{value.begin}-#{value.end}"
  else
    super(value)
  end
end

#validate(value) ⇒ Object



62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
# File 'lib/nikto/command.rb', line 62

def validate(value)
  case value
  when Array
    value.each do |element|
      valid, message = validate(element)

      unless valid
        return [valid, message]
      end
    end

    return true
  when Range
    valid, message = super(value.begin)

    unless valid
      return [valid, message]
    end

    valid, message = super(value.end)

    unless valid
      return [valid, message]
    end

    return true
  else
    super(value)
  end
end