Class: Facebooker::FqlMultiquery

Inherits:
Parser
  • Object
show all
Defined in:
lib/facebooker/parser.rb

Overview

nodoc

Constant Summary

Constants inherited from Parser

Parser::PARSERS

Class Method Summary collapse

Methods inherited from Parser

anonymous_field_from, array_of, array_of_hashes, array_of_text_values, booleanize, element, hash_by_key_or_value_for, hash_or_value_for, hashinate, hashinate_by_key, parse

Class Method Details

.process(data) ⇒ Object



535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
# File 'lib/facebooker/parser.rb', line 535

def self.process(data)
  root = element('fql_multiquery_response', data)
  root.children.reject { |child| child.text? }.map do |elm|
    elm.children.reject { |child| child.text? }.map do |query|
      if 'name' == query.name
        query.text
      else
        list = query.children.reject { |child| child.text? }
        if list.length == 0
          []
        else
          [list.first.name, array_of_hashes(query, list.first.name)]
        end
      end
    end
  end
end