Class: S3::ListBucketParser
- Inherits:
-
Object
- Object
- S3::ListBucketParser
- Defined in:
- lib/S3.rb
Overview
Parses the list bucket output into a list of ListEntry objects, and a list of CommonPrefixEntry objects if applicable.
Instance Attribute Summary collapse
-
#common_prefixes ⇒ Object
readonly
Returns the value of attribute common_prefixes.
-
#entries ⇒ Object
readonly
Returns the value of attribute entries.
-
#properties ⇒ Object
readonly
Returns the value of attribute properties.
Instance Method Summary collapse
-
#initialize ⇒ ListBucketParser
constructor
A new instance of ListBucketParser.
-
#reset ⇒ Object
get ready for another parse.
-
#tag_end(name) ⇒ Object
we have one, add him to the entries list.
- #tag_start(name, attributes) ⇒ Object
- #text(text) ⇒ Object
- #xmldecl(version, encoding, standalone) ⇒ Object
Constructor Details
#initialize ⇒ ListBucketParser
Returns a new instance of ListBucketParser.
564 565 566 |
# File 'lib/S3.rb', line 564 def initialize reset end |
Instance Attribute Details
#common_prefixes ⇒ Object (readonly)
Returns the value of attribute common_prefixes.
562 563 564 |
# File 'lib/S3.rb', line 562 def common_prefixes @common_prefixes end |
#entries ⇒ Object (readonly)
Returns the value of attribute entries.
561 562 563 |
# File 'lib/S3.rb', line 561 def entries @entries end |
#properties ⇒ Object (readonly)
Returns the value of attribute properties.
560 561 562 |
# File 'lib/S3.rb', line 560 def properties @properties end |
Instance Method Details
#reset ⇒ Object
get ready for another parse
633 634 635 636 637 638 639 640 |
# File 'lib/S3.rb', line 633 def reset @is_echoed_prefix = true; @entries = [] @curr_entry = nil @common_prefixes = [] @common_prefix_entry = nil @curr_text = '' end |
#tag_end(name) ⇒ Object
we have one, add him to the entries list
581 582 583 584 585 586 587 588 589 590 591 592 593 594 595 596 597 598 599 600 601 602 603 604 605 606 607 608 609 610 611 612 613 614 615 616 617 618 619 620 621 622 |
# File 'lib/S3.rb', line 581 def tag_end(name) text = @curr_text.strip # this prefix is the one we echo back from the request if name == 'Name' @properties.name = text elsif name == 'Prefix' and @is_echoed_prefix @properties.prefix = text @is_echoed_prefix = nil elsif name == 'Marker' @properties.marker = text elsif name == 'MaxKeys' @properties.max_keys = text.to_i elsif name == 'Delimiter' @properties.delimiter = text elsif name == 'IsTruncated' @properties.is_truncated = text == 'true' elsif name == 'NextMarker' @properties.next_marker = text elsif name == 'Contents' @entries << @curr_entry elsif name == 'Key' @curr_entry.key = text elsif name == 'LastModified' @curr_entry.last_modified = text elsif name == 'ETag' @curr_entry.etag = text elsif name == 'Size' @curr_entry.size = text.to_i elsif name == 'StorageClass' @curr_entry.storage_class = text elsif name == 'ID' @curr_entry.owner.id = text elsif name == 'DisplayName' @curr_entry.owner.display_name = text elsif name == 'CommonPrefixes' @common_prefixes << @common_prefix_entry elsif name == 'Prefix' # this is the common prefix for keys that match up to the delimiter @common_prefix_entry.prefix = text end @curr_text = '' end |
#tag_start(name, attributes) ⇒ Object
568 569 570 571 572 573 574 575 576 577 578 |
# File 'lib/S3.rb', line 568 def tag_start(name, attributes) if name == 'ListBucketResult' @properties = ListProperties.new elsif name == 'Contents' @curr_entry = ListEntry.new elsif name == 'Owner' @curr_entry.owner = Owner.new elsif name == 'CommonPrefixes' @common_prefix_entry = CommonPrefixEntry.new end end |
#text(text) ⇒ Object
624 625 626 |
# File 'lib/S3.rb', line 624 def text(text) @curr_text += text end |
#xmldecl(version, encoding, standalone) ⇒ Object
628 629 630 |
# File 'lib/S3.rb', line 628 def xmldecl(version, encoding, standalone) # ignore end |