Class: Fog::Parsers::AWS::Storage::GetBucketLifecycle

Inherits:
Base
  • Object
show all
Defined in:
lib/fog/aws/parsers/storage/get_bucket_lifecycle.rb

Instance Method Summary collapse

Instance Method Details

#end_element(name) ⇒ Object



29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
# File 'lib/fog/aws/parsers/storage/get_bucket_lifecycle.rb', line 29

def end_element(name)
  if @in_expiration
    case name
    when 'Days'
      @expiration[name] = value.to_i
    when 'Date'
      @expiration[name] = value
    when 'Expiration'
      @rule['Expiration'] = @expiration
      @in_expiration = false
      @expiration = {}
    end
  elsif @in_version_expiration
    case name
    when 'NoncurrentDays'
      @version_expiration[name] = value.to_i
    when 'Date'
      @version_expiration[name] = value
    when 'NoncurrentVersionExpiration'
      @rule['NoncurrentVersionExpiration'] = @version_expiration
      @in_version_expiration = false
      @version_expiration = {}
    end
  elsif @in_transition
    case name
    when 'StorageClass',
      @transition['StorageClass'] = value
    when 'Date'
      @transition[name] = value
    when 'Days'
      @transition[name] = value.to_i
    when 'Transition'
      @rule['Transition'] = @transition
      @in_transition = false
      @transition = {}
    end
  elsif @in_version_transition
    case name
    when 'StorageClass',
      @version_transition['StorageClass'] = value
    when 'Date'
      @version_transition[name] = value
    when 'NoncurrentDays'
      @version_transition[name] = value.to_i
    when 'NoncurrentVersionTransition'
      @rule['NoncurrentVersionTransition'] = @transition
      @in_version_transition = false
      @version_transition = {}
    end
  else
    case name
    when 'ID', 'Prefix'
      @rule[name] = value
    when 'Status'
      @rule['Enabled'] = value == 'Enabled'
    when 'Rule'
      @response['Rules'] << @rule
      @rule = {}
    end
  end
end

#resetObject



6
7
8
9
10
11
12
13
# File 'lib/fog/aws/parsers/storage/get_bucket_lifecycle.rb', line 6

def reset
  @expiration = {}
  @version_expiration = {}
  @transition = {}
  @version_transition = {}
  @rule = {}
  @response = { 'Rules' => [] }
end

#start_element(name, attrs = []) ⇒ Object



15
16
17
18
19
20
21
22
23
24
25
26
27
# File 'lib/fog/aws/parsers/storage/get_bucket_lifecycle.rb', line 15

def start_element(name, attrs=[])
  super
  case name
  when 'Expiration'
    @in_expiration = true
  when 'Transition'
    @in_transition = true
  when 'NoncurrentVersionExpiration'
    @in_version_expiration = true
  when 'NoncurrentVersionTransition'
    @in_version_transition = true
  end
end