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.



325
326
327
# File 'lib/nexpose/common.rb', line 325

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

Instance Attribute Details

#addressObject

Returns the value of attribute address.



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

def address
  @address
end

#cityObject

Returns the value of attribute city.



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

def city
  @city
end

#countryObject

Returns the value of attribute country.



323
324
325
# File 'lib/nexpose/common.rb', line 323

def country
  @country
end

#emailObject

Returns the value of attribute email.



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

def email
  @email
end

#job_titleObject

Returns the value of attribute job_title.



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

def job_title
  @job_title
end

#nameObject

Returns the value of attribute name.



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

def name
  @name
end

#primary_contactObject

Returns the value of attribute primary_contact.



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

def primary_contact
  @primary_contact
end

#stateObject

Returns the value of attribute state.



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

def state
  @state
end

#telephoneObject

Returns the value of attribute telephone.



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

def telephone
  @telephone
end

#urlObject

Returns the value of attribute url.



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

def url
  @url
end

#zipObject

Returns the value of attribute zip.



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

def zip
  @zip
end

Class Method Details

.create(hash) ⇒ Object

Create organization object from hash



345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
# File 'lib/nexpose/common.rb', line 345

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



361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
# File 'lib/nexpose/common.rb', line 361

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



377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
# File 'lib/nexpose/common.rb', line 377

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



329
330
331
332
333
334
335
336
337
338
339
340
341
342
# File 'lib/nexpose/common.rb', line 329

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