Class: Aliyun::Oss::Struct::LifeCycle

Inherits:
Base
  • Object
show all
Defined in:
lib/aliyun/oss/struct/lifecycle.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Methods inherited from Base

#initialize

Constructor Details

This class inherits a constructor from Aliyun::Oss::Struct::Base

Instance Attribute Details

#dateObject

Set auto auto delete object at given time, at least exist one with days, [Time]



18
19
20
# File 'lib/aliyun/oss/struct/lifecycle.rb', line 18

def date
  @date
end

#daysObject

Set auto delete objects after days since last modified, at least exist one with date [Integer]



15
16
17
# File 'lib/aliyun/oss/struct/lifecycle.rb', line 15

def days
  @days
end

#enabledObject

Used for set rule status. [Boolean]



12
13
14
# File 'lib/aliyun/oss/struct/lifecycle.rb', line 12

def enabled
  @enabled
end

#idObject

Rule ID, auto set when not set. [String]



6
7
8
# File 'lib/aliyun/oss/struct/lifecycle.rb', line 6

def id
  @id
end

#prefixObject

Used for filter objects. [String]



9
10
11
# File 'lib/aliyun/oss/struct/lifecycle.rb', line 9

def prefix
  @prefix
end

Instance Method Details

#expiration=(expiration) ⇒ Object



43
44
45
46
47
48
49
50
51
# File 'lib/aliyun/oss/struct/lifecycle.rb', line 43

def expiration=(expiration)
  return unless expiration.is_a?(Hash)

  if expiration.key?('Days')
    self.days = expiration['Days']
  elsif expiration.key?('Date')
    self.date = expiration['Date']
  end
end

#status=(status) ⇒ Object



20
21
22
# File 'lib/aliyun/oss/struct/lifecycle.rb', line 20

def status=(status)
  @enabled = (status == 'Enabled')
end

#to_hashObject



32
33
34
35
36
37
38
39
40
41
# File 'lib/aliyun/oss/struct/lifecycle.rb', line 32

def to_hash
  return {} unless valid?

  {
    'ID' => id || '',
    'Prefix' => prefix,
    'Status' => status,
    'Expiration' => expiration
  }
end

#valid?Boolean

Returns:

  • (Boolean)


53
54
55
# File 'lib/aliyun/oss/struct/lifecycle.rb', line 53

def valid?
  prefix && (days || date)
end