Class: SQSMessage

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

Instance Attribute Summary collapse

Class Method Summary collapse

Instance Attribute Details

#bodyObject

Returns the value of attribute body.



7
8
9
# File 'lib/sqs_async/sqs_message.rb', line 7

def body
  @body
end

#md5_of_bodyObject

Returns the value of attribute md5_of_body.



7
8
9
# File 'lib/sqs_async/sqs_message.rb', line 7

def md5_of_body
  @md5_of_body
end

#message_idObject

Returns the value of attribute message_id.



7
8
9
# File 'lib/sqs_async/sqs_message.rb', line 7

def message_id
  @message_id
end

#receipt_handleObject

Returns the value of attribute receipt_handle.



7
8
9
# File 'lib/sqs_async/sqs_message.rb', line 7

def receipt_handle
  @receipt_handle
end

Class Method Details

.parse(xml) ⇒ Object



9
10
11
12
13
14
15
16
17
18
19
20
21
# File 'lib/sqs_async/sqs_message.rb', line 9

def self.parse(xml)
  doc = Nokogiri::XML(xml)
  messages = []
  doc.search("Message").each do |message_element|
    s = SQSMessage.new
    s.body = message_element.at("Body").text.strip
    s.md5_of_body = message_element.at("MD5OfBody").text.strip
    s.message_id = message_element.at("MessageId").text.strip
    s.receipt_handle = message_element.at("ReceiptHandle").text.strip
    messages << s
  end
  messages
end