Class: Awsum::S3::BucketParser

Inherits:
Parser show all
Defined in:
lib/awsum/s3/parsers/bucket_parser.rb

Overview

:nodoc:

Instance Method Summary collapse

Methods inherited from Parser

#parse, #xmldecl

Constructor Details

#initialize(s3) ⇒ BucketParser

Returns a new instance of BucketParser.



4
5
6
7
8
# File 'lib/awsum/s3/parsers/bucket_parser.rb', line 4

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

Instance Method Details

#resultObject



38
39
40
# File 'lib/awsum/s3/parsers/bucket_parser.rb', line 38

def result
  @buckets
end

#tag_end(tag) ⇒ Object



22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
# File 'lib/awsum/s3/parsers/bucket_parser.rb', line 22

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



10
11
12
13
14
15
16
# File 'lib/awsum/s3/parsers/bucket_parser.rb', line 10

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

#text(text) ⇒ Object



18
19
20
# File 'lib/awsum/s3/parsers/bucket_parser.rb', line 18

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