Class: AWS::S3::BucketLifecycleConfiguration::Rule

Inherits:
Object
  • Object
show all
Defined in:
lib/aws/s3/bucket_lifecycle_configuration.rb

Overview

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/'

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(configuration, id, prefix, expiration_days, status) ⇒ Rule

Returns a new instance of Rule.



305
306
307
308
309
310
311
# File 'lib/aws/s3/bucket_lifecycle_configuration.rb', line 305

def initialize configuration, id, prefix, expiration_days, status
  @configuration = configuration
  @id = id
  @prefix = prefix
  @expiration_days = expiration_days
  @status = status
end

Instance Attribute Details

#configurationBucketLifecycleConfiguration (readonly)



314
315
316
# File 'lib/aws/s3/bucket_lifecycle_configuration.rb', line 314

def configuration
  @configuration
end

#expiration_daysInteger

Returns:

  • (Integer)


323
324
325
# File 'lib/aws/s3/bucket_lifecycle_configuration.rb', line 323

def expiration_days
  @expiration_days
end

#idString (readonly)

Returns:

  • (String)


317
318
319
# File 'lib/aws/s3/bucket_lifecycle_configuration.rb', line 317

def id
  @id
end

#prefixString

Returns:

  • (String)


320
321
322
# File 'lib/aws/s3/bucket_lifecycle_configuration.rb', line 320

def prefix
  @prefix
end

#statusString

Returns the rule status, ‘Enabled’ or ‘Disabled’

Returns:

  • (String)

    Returns the rule status, ‘Enabled’ or ‘Disabled’



326
327
328
# File 'lib/aws/s3/bucket_lifecycle_configuration.rb', line 326

def status
  @status
end

Instance Method Details

#disabled!Object



340
341
342
# File 'lib/aws/s3/bucket_lifecycle_configuration.rb', line 340

def disabled!
  self.status = 'Disabled'
end

#disabled?Boolean

Returns:

  • (Boolean)


336
337
338
# File 'lib/aws/s3/bucket_lifecycle_configuration.rb', line 336

def disabled?
  status == 'Disabled'
end

#enable!Object



332
333
334
# File 'lib/aws/s3/bucket_lifecycle_configuration.rb', line 332

def enable!
  self.status = 'Enabled'
end

#enabled?Boolean

Returns:

  • (Boolean)


328
329
330
# File 'lib/aws/s3/bucket_lifecycle_configuration.rb', line 328

def enabled?
  status == 'Enabled'
end

#eql?(other) ⇒ Boolean Also known as: ==

Returns:

  • (Boolean)


345
346
347
348
349
350
351
352
# File 'lib/aws/s3/bucket_lifecycle_configuration.rb', line 345

def eql? other
  other.is_a?(Rule) and
  other.configuration.bucket == configuration.bucket and
  other.id == id and
  other.prefix == prefix and
  other.expiration_days == expiration_days and
  other.status == status
end