Class: AdLocalize::Requests::GSpreadsheetOptions

Inherits:
Object
  • Object
show all
Defined in:
lib/ad_localize/requests/g_spreadsheet_options.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(**args) ⇒ GSpreadsheetOptions

Returns a new instance of GSpreadsheetOptions.



11
12
13
14
15
16
# File 'lib/ad_localize/requests/g_spreadsheet_options.rb', line 11

def initialize(**args)
  @spreadsheet_id = args[:spreadsheet_id]
  @sheet_ids = Array(args[:sheet_ids])
  @export_all = args[:export_all] || false
  @service_account_config = args[:service_account_config].presence
end

Instance Attribute Details

#export_allObject

Returns the value of attribute export_all.



4
5
6
# File 'lib/ad_localize/requests/g_spreadsheet_options.rb', line 4

def export_all
  @export_all
end

#service_account_configObject

Returns the value of attribute service_account_config.



4
5
6
# File 'lib/ad_localize/requests/g_spreadsheet_options.rb', line 4

def 
  @service_account_config
end

#sheet_idsObject

Returns the value of attribute sheet_ids.



4
5
6
# File 'lib/ad_localize/requests/g_spreadsheet_options.rb', line 4

def sheet_ids
  @sheet_ids
end

#spreadsheet_idObject

Returns the value of attribute spreadsheet_id.



4
5
6
# File 'lib/ad_localize/requests/g_spreadsheet_options.rb', line 4

def spreadsheet_id
  @spreadsheet_id
end

Instance Method Details

#has_multiple_sheets?Boolean

Returns:

  • (Boolean)


31
32
33
# File 'lib/ad_localize/requests/g_spreadsheet_options.rb', line 31

def has_multiple_sheets?
  export_all || @sheet_ids.size > 1
end

#public_download_urlsObject



22
23
24
25
26
27
28
29
# File 'lib/ad_localize/requests/g_spreadsheet_options.rb', line 22

def public_download_urls
  return [] if @service_account_config
  if @sheet_ids.size.zero?
    [public_download_url(sheet_id: nil)]
  else
    @sheet_ids.map { |sheet_id| public_download_url(sheet_id: sheet_id) }
  end
end

#valid?Boolean

Returns:

  • (Boolean)


18
19
20
# File 'lib/ad_localize/requests/g_spreadsheet_options.rb', line 18

def valid?
  (spreadsheet_id && !export_all) || (spreadsheet_id && .present?)
end