Class: Nexpose::WebCredentials::HTMLForm

Inherits:
Object
  • Object
show all
Defined in:
lib/nexpose/web_credentials.rb

Overview

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

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

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

Returns a new instance of HTMLForm.



154
155
156
157
158
159
160
# File 'lib/nexpose/web_credentials.rb', line 154

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.



146
147
148
# File 'lib/nexpose/web_credentials.rb', line 146

def action
  @action
end

#encTypeObject (readonly)

The HTTP encoding type with which to submit the form.



150
151
152
# File 'lib/nexpose/web_credentials.rb', line 150

def encType
  @encType
end

#fieldsObject (readonly)

The fields in the HTML Form



152
153
154
# File 'lib/nexpose/web_credentials.rb', line 152

def fields
  @fields
end

#methodObject (readonly)

The HTTP request method with which to submit the form.



148
149
150
# File 'lib/nexpose/web_credentials.rb', line 148

def method
  @method
end

#nameObject (readonly)

The name of the form being submitted.



144
145
146
# File 'lib/nexpose/web_credentials.rb', line 144

def name
  @name
end

Instance Method Details

#add_field(field) ⇒ Object



162
163
164
# File 'lib/nexpose/web_credentials.rb', line 162

def add_field(field)
  @fields << field.to_h
end

#to_hObject



170
171
172
173
174
175
176
177
# File 'lib/nexpose/web_credentials.rb', line 170

def to_h
  { name: name,
    action: action,
    method: method,
    encType: encType,
    fields: fields,
    parentPage: action }
end

#to_jsonObject



166
167
168
# File 'lib/nexpose/web_credentials.rb', line 166

def to_json
  JSON.generate(to_h)
end