Class: DmLiveResources::GSheet
- Inherits:
-
Object
- Object
- DmLiveResources::GSheet
- Includes:
- HTTParty
- Defined in:
- lib/dm_live_resources/g_sheet.rb
Instance Attribute Summary collapse
-
#api_key ⇒ Object
readonly
Returns the value of attribute api_key.
-
#content ⇒ Object
readonly
Returns the value of attribute content.
-
#content_type ⇒ Object
readonly
Returns the value of attribute content_type.
-
#exported_file ⇒ Object
readonly
Returns the value of attribute exported_file.
-
#identifier ⇒ Object
readonly
Returns the value of attribute identifier.
-
#sheets ⇒ Object
readonly
Returns the value of attribute sheets.
-
#title ⇒ Object
readonly
Returns the value of attribute title.
Instance Method Summary collapse
- #get_title ⇒ Object
-
#initialize(args = {}) ⇒ GSheet
constructor
A new instance of GSheet.
- #ranges ⇒ Object
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_key ⇒ Object (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 |
#content ⇒ Object (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_type ⇒ Object (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_file ⇒ Object (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 |
#identifier ⇒ Object (readonly)
Returns the value of attribute identifier.
6 7 8 |
# File 'lib/dm_live_resources/g_sheet.rb', line 6 def identifier @identifier end |
#sheets ⇒ Object (readonly)
Returns the value of attribute sheets.
6 7 8 |
# File 'lib/dm_live_resources/g_sheet.rb', line 6 def sheets @sheets end |
#title ⇒ Object (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_title ⇒ Object
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 |
#ranges ⇒ Object
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 |