Class: RmsWebService::Response::Item::Parser
- Inherits:
-
Array
- Object
- Array
- RmsWebService::Response::Item::Parser
- Defined in:
- lib/rms_web_service/response/item/parser.rb
Instance Attribute Summary collapse
-
#status ⇒ Object
Returns the value of attribute status.
Instance Method Summary collapse
-
#initialize(xml) ⇒ Parser
constructor
A new instance of Parser.
- #set_attribute(name, content) ⇒ Object
- #set_attributes(args) ⇒ Object
Constructor Details
#initialize(xml) ⇒ Parser
Returns a new instance of Parser.
8 9 10 11 12 13 14 |
# File 'lib/rms_web_service/response/item/parser.rb', line 8 def initialize(xml) @parsed_xml = Nokogiri::XML.parse(xml) @status = Item::Status.new(xml) @code = @parsed_xml.xpath("//code").first.content if @parsed_xml.xpath("//code").present? @errors = [] @parsed_xml.xpath("//errorMessages").children.each {|error| @errors << Error.parse(error.to_s)} if @parsed_xml.xpath("//errorMessages").present? end |
Instance Attribute Details
#status ⇒ Object
Returns the value of attribute status.
7 8 9 |
# File 'lib/rms_web_service/response/item/parser.rb', line 7 def status @status end |
Instance Method Details
#set_attribute(name, content) ⇒ Object
20 21 22 |
# File 'lib/rms_web_service/response/item/parser.rb', line 20 def set_attribute(name, content) self.define_singleton_method(name.underscore) {content} end |
#set_attributes(args) ⇒ Object
16 17 18 |
# File 'lib/rms_web_service/response/item/parser.rb', line 16 def set_attributes(args) args.each {|s| set_attribute(s.name, s.content)} end |