Class: RmsWebService::Response::Item::Parser

Inherits:
Array
  • Object
show all
Defined in:
lib/rms_web_service/response/item/parser.rb

Direct Known Subclasses

Delete, Get, Insert, ItemsUpdate, Search, Status, Update

Instance Attribute Summary collapse

Instance Method Summary collapse

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

#statusObject

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