Module: Dustbag::Parser

Extended by:
Parser
Included in:
Parser
Defined in:
lib/dustbag/parser.rb,
lib/dustbag/parser/node.rb,
lib/dustbag/parser/collection_node.rb,
lib/dustbag/parser/map_collection_node.rb

Defined Under Namespace

Modules: CollectionNode, MapCollectionNode, Node Classes: Error

Instance Method Summary collapse

Instance Method Details

#parse(body) ⇒ Object

Raises:



7
8
9
10
11
12
13
14
15
16
17
18
19
20
# File 'lib/dustbag/parser.rb', line 7

def parse(body)
  document = Ox.parse(body)

  raise Error.new('Not a Ox::Document') unless document.is_a?(Ox::Document)

  response_type = document.root.name

  case response_type
  when 'ItemSearchResponse'
    ItemSearchResponse.new(document.root)
  else
    raise Error.new(response_type + ' is not implemented!')
  end
end