Class: S3::ErrorResponseParser

Inherits:
Object
  • Object
show all
Defined in:
lib/S3.rb

Instance Attribute Summary collapse

Class Method Summary collapse

Instance Method Summary collapse

Constructor Details

#initializeErrorResponseParser

Returns a new instance of ErrorResponseParser.



695
696
697
698
# File 'lib/S3.rb', line 695

def initialize
  @state = :init
  @code = nil
end

Instance Attribute Details

#codeObject (readonly)

Returns the value of attribute code.



687
688
689
# File 'lib/S3.rb', line 687

def code
  @code
end

Class Method Details

.parse(msg) ⇒ Object



689
690
691
692
693
# File 'lib/S3.rb', line 689

def self.parse(msg)
    parser = ErrorResponseParser.new
    REXML::Document.parse_stream(msg, parser)
    parser.code
end

Instance Method Details

#tag_end(name) ⇒ Object

we have one, add him to the entries list



719
720
721
722
723
724
# File 'lib/S3.rb', line 719

def tag_end(name)
  case @state
  when :tag_code
    @state = :done
  end
end

#tag_start(name, attributes) ⇒ Object



700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
# File 'lib/S3.rb', line 700

def tag_start(name, attributes)
  case @state
  when :init
    if name == 'Error'
      @state = :tag_error
    else
      @state = :bad
    end
  when :tag_error
    if name == 'Code'
      @state = :tag_code
      @code = ''
    else
      @state = :bad
    end
  end
end

#text(text) ⇒ Object



726
727
728
# File 'lib/S3.rb', line 726

def text(text)
  @code += text if @state == :tag_code
end

#xmldecl(version, encoding, standalone) ⇒ Object



730
731
732
# File 'lib/S3.rb', line 730

def xmldecl(version, encoding, standalone)
  # ignore
end