class AWS::S3::BucketLifecycleConfiguration::Rule

Represents a single rule from an Amazon S3 bucket lifecycle configuration.

# delete all objects with the prefix 'temporary/' after 10 days
bucket.lifecycle_configuration.add_rule 'temporary/', 10

# remove the rule created above
bucket.lifecycle_configuration.remove_rule 'temporary/'

Attributes

configuration[R]

@return [BucketLifecycleConfiguration]

expiration_days[R]

@return [Date] the date the objects will expire @return [Integer] if the value is an integer, returns the number

of days before the object will expire.
expiration_time[R]

@return [Date] the date the objects will expire @return [Integer] if the value is an integer, returns the number

of days before the object will expire.
glacier_transition_time[R]

@return [Date] the date the objects will be

transitioned into the Amazon Glacier storage tier.

@return [Integer] if the value is an integer, returns the number

of days before the object is transitioned into the Amazon Glacier
storage tier.
id[R]

@return [String]

prefix[RW]

@return [String]

status[RW]

@return [String] Returns the rule status, 'Enabled' or 'Disabled'

Public Class Methods

new(configuration, id, prefix, expiration_time = nil, status = nil) click to toggle source

@api private

# File lib/aws/s3/bucket_lifecycle_configuration.rb, line 338
def initialize configuration, id, prefix, expiration_time = nil, status = nil
  @configuration = configuration
  @id = id
  @prefix = prefix

  if Hash === expiration_time
    options = expiration_time
    options.each do |key, value|
      send("#{key}=", value) if respond_to?("#{key}=")
    end
  else
    self.expiration_time = expiration_time
    self.status = status
  end
end

Public Instance Methods

==(other)
Alias for: eql?
disabled!() click to toggle source
# File lib/aws/s3/bucket_lifecycle_configuration.rb, line 403
def disabled!
  self.status = 'Disabled'
end
disabled?() click to toggle source
# File lib/aws/s3/bucket_lifecycle_configuration.rb, line 399
def disabled?
  status == 'Disabled'
end
enable!() click to toggle source
# File lib/aws/s3/bucket_lifecycle_configuration.rb, line 395
def enable!
  self.status = 'Enabled'
end
enabled?() click to toggle source
# File lib/aws/s3/bucket_lifecycle_configuration.rb, line 391
def enabled?
  status == 'Enabled'
end
eql?(other) click to toggle source

@api private

# File lib/aws/s3/bucket_lifecycle_configuration.rb, line 408
def eql? other
  other.is_a?(Rule) and
  other.configuration.bucket == configuration.bucket and
  other.id == id and
  other.prefix == prefix and
  other.expiration_time == expiration_time and
  other.glacier_transition_time == glacier_transition_time and
  other.status == status
end
Also aliased as: ==
expiration_days=(value)
Alias for: expiration_time=
expiration_time=(value) click to toggle source

Converts any time values to Date objects

# File lib/aws/s3/bucket_lifecycle_configuration.rb, line 369
def expiration_time=(value)
  @expiration_time = convert_time_value(value)
end
Also aliased as: expiration_days=
glacier_transition_time=(value) click to toggle source

Converts any time values to Date objects

# File lib/aws/s3/bucket_lifecycle_configuration.rb, line 384
def glacier_transition_time=(value)
  @glacier_transition_time = convert_time_value(value)
end

Private Instance Methods

convert_time_value(value) click to toggle source

If an integer, returns the integer as days, otherwise converts any time-like values into Date objects @return [Integer] if the value is an integer @return [Date] if the value is a time-like object @return [nil] if the value is nil

# File lib/aws/s3/bucket_lifecycle_configuration.rb, line 426
def convert_time_value(value)
  return nil if value.nil?
  return value if value.is_a?(Integer)
  Date.parse(value.to_s)
end