Class: DmLiveResources::GSheet

Inherits:
Object
  • Object
show all
Includes:
HTTParty
Defined in:
lib/dm_live_resources/g_sheet.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(args = {}) ⇒ GSheet

Returns a new instance of GSheet.



9
10
11
12
13
14
# File 'lib/dm_live_resources/g_sheet.rb', line 9

def initialize(args = {})
			@api_key = args[:gs_api_key]
			@identifier = args[:gs_identifier]
			@title = args[:gs_title] ||= get_title
			@sheets = args[:gs_sheets] ||= "Sheet1"
end

Instance Attribute Details

#api_keyObject (readonly)

Returns the value of attribute api_key.



6
7
8
# File 'lib/dm_live_resources/g_sheet.rb', line 6

def api_key
  @api_key
end

#contentObject (readonly)

Returns the value of attribute content.



6
7
8
# File 'lib/dm_live_resources/g_sheet.rb', line 6

def content
  @content
end

#content_typeObject (readonly)

Returns the value of attribute content_type.



6
7
8
# File 'lib/dm_live_resources/g_sheet.rb', line 6

def content_type
  @content_type
end

#exported_fileObject (readonly)

Returns the value of attribute exported_file.



6
7
8
# File 'lib/dm_live_resources/g_sheet.rb', line 6

def exported_file
  @exported_file
end

#identifierObject (readonly)

Returns the value of attribute identifier.



6
7
8
# File 'lib/dm_live_resources/g_sheet.rb', line 6

def identifier
  @identifier
end

#sheetsObject (readonly)

Returns the value of attribute sheets.



6
7
8
# File 'lib/dm_live_resources/g_sheet.rb', line 6

def sheets
  @sheets
end

#titleObject (readonly)

Returns the value of attribute title.



6
7
8
# File 'lib/dm_live_resources/g_sheet.rb', line 6

def title
  @title
end

Instance Method Details

#get_titleObject



26
27
28
29
30
# File 'lib/dm_live_resources/g_sheet.rb', line 26

def get_title
	params = { mimeType: content_type, key: api_key }
	request = self.class.get("https://www.googleapis.com/drive/v3/files/#{identifier}", query: params)
	@title = request["name"]
end

#rangesObject



32
33
34
35
36
37
# File 'lib/dm_live_resources/g_sheet.rb', line 32

def ranges
	split_sheets = sheets.split(", ")
	range = split_sheets.map {|sheet| "ranges=#{sheet}"}
	range = range.join("&")
	return range
end