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.



239
240
241
242
243
244
245
# File 'lib/nexpose/creds.rb', line 239

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.



231
232
233
# File 'lib/nexpose/creds.rb', line 231

def action
  @action
end

#enctypeObject (readonly)

The HTTP encoding type with which to submit the form.



235
236
237
# File 'lib/nexpose/creds.rb', line 235

def enctype
  @enctype
end

#fieldsObject (readonly)

The fields in the HTML Form



237
238
239
# File 'lib/nexpose/creds.rb', line 237

def fields
  @fields
end

#methodObject (readonly)

The HTTP request method with which to submit the form.



233
234
235
# File 'lib/nexpose/creds.rb', line 233

def method
  @method
end

#nameObject (readonly)

The name of the form being submitted.



229
230
231
# File 'lib/nexpose/creds.rb', line 229

def name
  @name
end

Instance Method Details

#add_field(field) ⇒ Object



247
248
249
# File 'lib/nexpose/creds.rb', line 247

def add_field(field)
  @fields << field
end

#to_xml_elemObject



251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
# File 'lib/nexpose/creds.rb', line 251

def to_xml_elem
  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