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
128
129
# File 'lib/nexpose/tag.rb', line 125

def initialize(name, type, id)
  @name = name
  @type = type
  @id   = 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



131
132
133
# File 'lib/nexpose/tag.rb', line 131

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

.parse_xml(xml) ⇒ Object



135
136
137
# File 'lib/nexpose/tag.rb', line 135

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



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

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