Class: Nexpose::TagSummary

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

Overview

Summary value object for tag information

Direct Known Subclasses

Tag

Instance Attribute Summary collapse

Class Method Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(name, type, id) ⇒ TagSummary

Returns a new instance of TagSummary.



125
126
127
# File 'lib/nexpose/tag.rb', line 125

def initialize(name, type, id)
  @name, @type, @id = name, type, id
end

Instance Attribute Details

#idObject

ID of tag



117
118
119
# File 'lib/nexpose/tag.rb', line 117

def id
  @id
end

#nameObject

Name of tag



120
121
122
# File 'lib/nexpose/tag.rb', line 120

def name
  @name
end

#typeObject

One of Tag::Type::Generic



123
124
125
# File 'lib/nexpose/tag.rb', line 123

def type
  @type
end

Class Method Details

.parse(json) ⇒ Object



129
130
131
# File 'lib/nexpose/tag.rb', line 129

def self.parse(json)
  new(json['tag_name'], json['tag_type'], json['tag_id'])
end

.parse_xml(xml) ⇒ Object



133
134
135
# File 'lib/nexpose/tag.rb', line 133

def self.parse_xml(xml)
  new(xml.attributes['name'], xml.attributes['type'], xml.attributes['id'].to_i)
end

Instance Method Details

#as_xmlELEMENT

XML representation of the tag summary as required by Site and AssetGroup

Returns:

  • (ELEMENT)

    XML element



141
142
143
144
145
146
147
# File 'lib/nexpose/tag.rb', line 141

def as_xml
  xml = REXML::Element.new('Tag')
  xml.add_attribute('id', @id)
  xml.add_attribute('name', @name)
  xml.add_attribute('type', @type)
  xml
end