Class: Awsum::S3::BucketParser

Inherits:
Parser show all
Defined in:
lib/s3/bucket.rb

Overview

:nodoc:

Instance Method Summary collapse

Methods inherited from Parser

#parse, #xmldecl

Constructor Details

#initialize(s3) ⇒ BucketParser

Returns a new instance of BucketParser.



27
28
29
30
31
# File 'lib/s3/bucket.rb', line 27

def initialize(s3)
  @s3 = s3
  @buckets = []
  @text = nil
end

Instance Method Details

#resultObject



61
62
63
# File 'lib/s3/bucket.rb', line 61

def result
  @buckets
end

#tag_end(tag) ⇒ Object



45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
# File 'lib/s3/bucket.rb', line 45

def tag_end(tag)
  case tag
    when 'Bucket'
      @buckets << Bucket.new(
                    @s3,
                    @current['Name'],
                    Time.parse(@current['CreationDate'])
                  )
      @text = nil
      @current = nil
    else
      text = @text.strip unless @text.nil?
      @current[tag] = (text == '' ? nil : text) unless @current.nil?
  end
end

#tag_start(tag, attributes) ⇒ Object



33
34
35
36
37
38
39
# File 'lib/s3/bucket.rb', line 33

def tag_start(tag, attributes)
  case tag
    when 'Bucket'
      @current = {}
      @text = ''
  end
end

#text(text) ⇒ Object



41
42
43
# File 'lib/s3/bucket.rb', line 41

def text(text)
  @text << text unless @text.nil?
end