Class: GoogleSpreadsheets::List::Format

Inherits:
GDataFormat show all
Defined in:
lib/google_spreadsheets/list.rb

Instance Method Summary collapse

Methods inherited from GDataFormat

#extension, #mime_type

Instance Method Details

#decode(xml) ⇒ Object



4
5
6
7
# File 'lib/google_spreadsheets/list.rb', line 4

def decode(xml)
  xml.force_encoding('UTF-8') # cf. http://d.hatena.ne.jp/kitamomonga/20101218/ruby_19_net_http_encoding
  super(xml.gsub(/<(\/?)gsx:/u, '<\1gsx_'))
end

#encode(hash, options = {}) ⇒ Object



8
9
10
11
# File 'lib/google_spreadsheets/list.rb', line 8

def encode(hash, options = {})
  super(Hash[*hash.map{|p| /^gsx_(.+)/ === p[0] ? ['gsx:'+$1, p[1]] : nil }.compact.flatten],
        { :namespaces => { 'gsx' => 'http://schemas.google.com/spreadsheets/2006/extended' } })
end