Class: GoogleDoc

Inherits:
Object
  • Object
show all
Defined in:
lib/csvconverter/google_doc.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Instance Attribute Details

#sessionObject

Returns the value of attribute session.



12
13
14
# File 'lib/csvconverter/google_doc.rb', line 12

def session
  @session
end

Instance Method Details

#authenticateObject



14
15
16
17
# File 'lib/csvconverter/google_doc.rb', line 14

def authenticate
  # will try to get token from ~/.ruby_google_drive.token
  @session = GoogleDrive.saved_session
end

#download(requested_filename, output_filename = "translations.csv") ⇒ Object



19
20
21
22
23
24
25
26
27
28
29
30
31
32
# File 'lib/csvconverter/google_doc.rb', line 19

def download(requested_filename, output_filename = "translations.csv")
  unless @session
    self.authenticate
  end
  result = @session.file_by_title(requested_filename)
  if result.is_a? Array
    file = result.first
  else
    file = result
  end
  return nil unless file
  file.export_as_file(output_filename, "csv")
  return output_filename
end