Class: Nexpose::Organization

Inherits:
APIObject show all
Defined in:
lib/nexpose/common.rb

Overview

Organization configuration, as used in Site and Silo.

Instance Attribute Summary collapse

Class Method Summary collapse

Instance Method Summary collapse

Methods inherited from APIObject

#object_from_hash

Constructor Details

#initialize(&block) ⇒ Organization

Returns a new instance of Organization.



321
322
323
# File 'lib/nexpose/common.rb', line 321

def initialize(&block)
  instance_eval(&block) if block_given?
end

Instance Attribute Details

#addressObject

Returns the value of attribute address.



315
316
317
# File 'lib/nexpose/common.rb', line 315

def address
  @address
end

#cityObject

Returns the value of attribute city.



317
318
319
# File 'lib/nexpose/common.rb', line 317

def city
  @city
end

#countryObject

Returns the value of attribute country.



319
320
321
# File 'lib/nexpose/common.rb', line 319

def country
  @country
end

#emailObject

Returns the value of attribute email.



313
314
315
# File 'lib/nexpose/common.rb', line 313

def email
  @email
end

#job_titleObject

Returns the value of attribute job_title.



312
313
314
# File 'lib/nexpose/common.rb', line 312

def job_title
  @job_title
end

#nameObject

Returns the value of attribute name.



309
310
311
# File 'lib/nexpose/common.rb', line 309

def name
  @name
end

#primary_contactObject

Returns the value of attribute primary_contact.



311
312
313
# File 'lib/nexpose/common.rb', line 311

def primary_contact
  @primary_contact
end

#stateObject

Returns the value of attribute state.



316
317
318
# File 'lib/nexpose/common.rb', line 316

def state
  @state
end

#telephoneObject

Returns the value of attribute telephone.



314
315
316
# File 'lib/nexpose/common.rb', line 314

def telephone
  @telephone
end

#urlObject

Returns the value of attribute url.



310
311
312
# File 'lib/nexpose/common.rb', line 310

def url
  @url
end

#zipObject

Returns the value of attribute zip.



318
319
320
# File 'lib/nexpose/common.rb', line 318

def zip
  @zip
end

Class Method Details

.create(hash) ⇒ Object

Create organization object from hash



340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
# File 'lib/nexpose/common.rb', line 340

def self.create(hash)
  new do |org|
    org.name            = hash[:name]
    org.url             = hash[:url]
    org.primary_contact = hash[:primary_contact]
    org.job_title       = hash[:job_title]
    org.email           = hash[:email]
    org.telephone       = hash[:telephone]
    org.address         = hash[:address]
    org.state           = hash[:state]
    org.city            = hash[:city]
    org.zip             = hash[:zip]
    org.country         = hash[:country]
  end
end

.parse(xml) ⇒ Object



356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
# File 'lib/nexpose/common.rb', line 356

def self.parse(xml)
  new do |org|
    org.name            = xml.attributes['name']
    org.url             = xml.attributes['url']
    org.primary_contact = xml.attributes['primaryContact']
    org.job_title       = xml.attributes['jobTitle']
    org.email           = xml.attributes['email']
    org.telephone       = xml.attributes['telephone']
    org.address         = xml.attributes['businessAddress']
    org.state           = xml.attributes['state']
    org.city            = xml.attributes['city']
    org.zip             = xml.attributes['zip']
    org.country         = xml.attributes['country']
  end
end

Instance Method Details

#as_xmlObject



372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
# File 'lib/nexpose/common.rb', line 372

def as_xml
  xml = REXML::Element.new('Organization')
  xml.add_attribute('name', @name)
  xml.add_attribute('url', @url)
  xml.add_attribute('primaryContact', @primary_contact)
  xml.add_attribute('jobTitle', @job_title)
  xml.add_attribute('email', @email)
  xml.add_attribute('telephone', @telephone)
  xml.add_attribute('businessAddress', @address)
  xml.add_attribute('state', @state)
  xml.add_attribute('city', @city)
  xml.add_attribute('zip', @zip)
  xml.add_attribute('country', @country)
  xml
end

#to_hObject



325
326
327
328
329
330
331
332
333
334
335
336
337
# File 'lib/nexpose/common.rb', line 325

def to_h
  { name: name,
    url: url,
    primary_contact: primary_contact,
    job_title: job_title,
    email: email,
    telephone: telephone,
    address: address,
    state: state,
    city: city,
    zip: zip,
    country: country }
end