Sha256: 638176a0c1e416b073dab0ef996e6b9a1e55cb2b0ce4a28150870ca6c0e3cc99

Contents?: true

Size: 838 Bytes

Versions: 2

Compression:

Stored size: 838 Bytes

Contents

# encoding: utf-8
module Laximo

  module Respond

    class FindOem < Laximo::Respond::Base

      def parsing_result(str)

        str.xpath('//FindOEM/detail').inject([]) { |arr, node|

          h = attrs_to_hash(node)

          h[:images] = node.xpath('./images/image').inject([]) { |arr1, n1|
            arr1 << attrs_to_hash(n1)
          }

          h[:properties] = node.xpath('./properties/property').inject([]) { |arr1, n1|
            arr1 << attrs_to_hash(n1)
          }

          h[:replacements] = node.xpath('./replacements/replacement').inject([]) { |arr1, n1|

            h1 = attrs_to_hash(n1)
            h2 = attrs_to_hash(n1.children[0])
            h1.merge!(h2)

            arr1 << h1

          }

          arr << h

        }

      end # parsing_result

    end # FindOem

  end # Respond

end # Laximo

Version data entries

2 entries across 2 versions & 1 rubygems

Version Path
laximo-0.3.3 lib/laximo/respond/find_oem.rb
laximo-0.3.2 lib/laximo/respond/find_oem.rb