Class: GoogleSpreadsheets::GDataFormat

Inherits:
Object
  • Object
show all
Defined in:
lib/google_spreadsheets/g_data_format.rb

Instance Method Summary collapse

Instance Method Details

#decode(xml) ⇒ Object



7
8
9
10
11
12
13
14
15
# File 'lib/google_spreadsheets/g_data_format.rb', line 7

def decode(xml)
  e = Hash.from_xml(xml)
  if e.has_key?('feed')
    e = e['feed']['entry'] || []
    (e.is_a?(Array) ? e : [e]).each{|i| format_entry(i) }
  else
    format_entry(e['entry'])
  end
end

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



16
17
18
19
20
21
22
23
24
25
26
# File 'lib/google_spreadsheets/g_data_format.rb', line 16

def encode(hash, options = {})
  root = REXML::Element.new('entry')
  root.add_namespace('http://www.w3.org/2005/Atom')
  (options[:namespaces] || {}).each{|key, value| root.add_namespace(key, value) }
  hash.each do |key, value|
    next unless value
    e = REXML::Element.new(key, root)
    e.text = value
  end
  root.to_s
end

#extensionObject



5
# File 'lib/google_spreadsheets/g_data_format.rb', line 5

def extension() '' end

#mime_typeObject



6
# File 'lib/google_spreadsheets/g_data_format.rb', line 6

def mime_type() 'application/atom+xml' end