Sha256: ba7f354d8ef0b813b1df9d906037347fb22335fc47e2acdd40629321645565a7

Contents?: true

Size: 686 Bytes

Versions: 1

Compression:

Stored size: 686 Bytes

Contents

require 'nokogiri'

module GoogleDataSource
  module DataSource
    class XmlData < Base
      #include ActionView::Helpers::NumberHelper
      def response
        cols = columns.map { |col| col.id || col.type }
        builder = ::Nokogiri::XML::Builder.new(:encoding => 'UTF-8') do |xml|
          xml.send(xml_class.pluralize, :type => 'array') do
            data.each do |datarow|
              xml.send(xml_class) do
                datarow.zip(cols).each do |val, key|
                  xml.send("#{key}", val.is_a?(Hash) ? val[:v] : val)
                end
              end
            end
          end
        end
       
        builder.to_xml
      end
    end
  end
end

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
google_data_source-0.7.6 lib/google_data_source/xml_data.rb