Class: AWS::EC2::Tag

Inherits:
Resource
  • Object
show all
Defined in:
lib/aws/ec2/tag.rb

Overview

Represents an EC2 tag.

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(resource, key, options = {}) ⇒ Tag

Returns a new instance of Tag.

Parameters:

  • key (String)

    The name of the tag

  • options (Hash) (defaults to: {})

Options Hash (options):

  • :value (String) — default: ''

    The optional value of the tag.



26
27
28
29
30
# File 'lib/aws/ec2/tag.rb', line 26

def initialize resource, key, options = {}
  @resource = resource
  @key = key.to_s
  super
end

Instance Attribute Details

#keyString (readonly) Also known as: name

Returns The name of this tag.

Returns:

  • (String)

    The name of this tag.



36
37
38
# File 'lib/aws/ec2/tag.rb', line 36

def key
  @key
end

#resourceObject (readonly)

Returns The EC2 resource this tag belongs to.

Returns:

  • (Object)

    The EC2 resource this tag belongs to.



33
34
35
# File 'lib/aws/ec2/tag.rb', line 33

def resource
  @resource
end

Instance Method Details

#delete(value = nil) ⇒ nil

Deletes this tag.

Returns:

  • (nil)


46
47
48
49
50
51
# File 'lib/aws/ec2/tag.rb', line 46

def delete(value = nil)
  tag_opts = { :key => key }
  tag_opts[:value] = value if value
  client.delete_tags(:resources => [resource.id], :tags => [tag_opts])
  nil
end

#valueString

Returns The tag value.

Returns:

  • (String)

    The tag value.



41
# File 'lib/aws/ec2/tag.rb', line 41

def value; end