Class: Nexpose::HTMLForm

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

Overview

When using HTML form, this represents the login form information.

Instance Attribute Summary collapse

Instance Method Summary collapse

Methods included from XMLUtils

#make_xml, #parse_xml, success?

Constructor Details

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

Returns a new instance of HTMLForm.



248
249
250
251
252
253
254
# File 'lib/nexpose/site_credential.rb', line 248

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.



240
241
242
# File 'lib/nexpose/site_credential.rb', line 240

def action
  @action
end

#enctypeObject (readonly)

The HTTP encoding type with which to submit the form.



244
245
246
# File 'lib/nexpose/site_credential.rb', line 244

def enctype
  @enctype
end

#fieldsObject (readonly)

The fields in the HTML Form



246
247
248
# File 'lib/nexpose/site_credential.rb', line 246

def fields
  @fields
end

#methodObject (readonly)

The HTTP request method with which to submit the form.



242
243
244
# File 'lib/nexpose/site_credential.rb', line 242

def method
  @method
end

#nameObject (readonly)

The name of the form being submitted.



238
239
240
# File 'lib/nexpose/site_credential.rb', line 238

def name
  @name
end

Instance Method Details

#add_field(field) ⇒ Object



256
257
258
# File 'lib/nexpose/site_credential.rb', line 256

def add_field(field)
  @fields << field
end

#as_xmlObject Also known as: to_xml_elem



260
261
262
263
264
265
266
267
268
269
270
271
272
273
# File 'lib/nexpose/site_credential.rb', line 260

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