Class: Nexpose::HTMLForm

Inherits:
Object
  • Object
show all
Includes:
XMLUtils
Defined in:
lib/nexpose/creds.rb

Overview

When using htmlform, this represents the login form information.

Instance Attribute Summary collapse

Instance Method Summary collapse

Methods included from XMLUtils

#make_xml, #parse_xml

Constructor Details

#initialize(name, action, method, enctype) ⇒ HTMLForm

Returns a new instance of HTMLForm.



299
300
301
302
303
304
305
# File 'lib/nexpose/creds.rb', line 299

def initialize(name, action, method, enctype)
  @name = name
  @action = action
  @method = method
  @enctype = enctype
  @fields = []
end

Instance Attribute Details

#actionObject (readonly)

The HTTP action (URL) through which to submit the login form.



291
292
293
# File 'lib/nexpose/creds.rb', line 291

def action
  @action
end

#enctypeObject (readonly)

The HTTP encoding type with which to submit the form.



295
296
297
# File 'lib/nexpose/creds.rb', line 295

def enctype
  @enctype
end

#fieldsObject (readonly)

The fields in the HTML Form



297
298
299
# File 'lib/nexpose/creds.rb', line 297

def fields
  @fields
end

#methodObject (readonly)

The HTTP request method with which to submit the form.



293
294
295
# File 'lib/nexpose/creds.rb', line 293

def method
  @method
end

#nameObject (readonly)

The name of the form being submitted.



289
290
291
# File 'lib/nexpose/creds.rb', line 289

def name
  @name
end

Instance Method Details

#add_field(field) ⇒ Object



307
308
309
# File 'lib/nexpose/creds.rb', line 307

def add_field(field)
  @fields << field
end

#as_xmlObject Also known as: to_xml_elem



311
312
313
314
315
316
317
318
319
320
321
322
323
324
# File 'lib/nexpose/creds.rb', line 311

def as_xml
  attributes = {}
  attributes['name'] = @name
  attributes['action'] = @action
  attributes['method'] = @method
  attributes['enctype'] = @enctype

  xml = make_xml('HTMLForm', attributes)

  fields.each() do |field|
    xml.add_element(field.to_xml_elem)
  end
  xml
end