Class: SpreadsheetToJson::Spreadsheet
- Inherits:
-
Object
- Object
- SpreadsheetToJson::Spreadsheet
- Defined in:
- lib/spreadsheet_to_json/spreadsheet.rb
Instance Attribute Summary collapse
-
#spreadsheet ⇒ Object
readonly
Returns the value of attribute spreadsheet.
Instance Method Summary collapse
-
#get_sheet_by_id(worksheet_id = 0) ⇒ Object
Get a sheet by worksheet’s id.
-
#get_sheet_by_name(worksheet_name) ⇒ Object
Get a sheet by a worksheet’s name.
-
#initialize(options = {}) ⇒ Spreadsheet
constructor
Initalize the spreadsheet with options hash inlcuding access_token and spreadsheet_key.
Constructor Details
#initialize(options = {}) ⇒ Spreadsheet
Initalize the spreadsheet with options hash inlcuding access_token and spreadsheet_key
7 8 9 10 11 12 13 14 15 |
# File 'lib/spreadsheet_to_json/spreadsheet.rb', line 7 def initialize( = {}) if .empty? puts "Please pass the parameter options with keys of access_token and spreadsheet_key" exit end session = GoogleDrive.login_with_oauth([:access_token]) @spreadsheet = session.spreadsheet_by_key([:spreadsheet_key]) end |
Instance Attribute Details
#spreadsheet ⇒ Object (readonly)
Returns the value of attribute spreadsheet.
5 6 7 |
# File 'lib/spreadsheet_to_json/spreadsheet.rb', line 5 def spreadsheet @spreadsheet end |
Instance Method Details
#get_sheet_by_id(worksheet_id = 0) ⇒ Object
Get a sheet by worksheet’s id
18 19 20 |
# File 'lib/spreadsheet_to_json/spreadsheet.rb', line 18 def get_sheet_by_id(worksheet_id=0) spreadsheet.worksheets[worksheet_id] end |
#get_sheet_by_name(worksheet_name) ⇒ Object
Get a sheet by a worksheet’s name
23 24 25 |
# File 'lib/spreadsheet_to_json/spreadsheet.rb', line 23 def get_sheet_by_name(worksheet_name) spreadsheet.worksheet_by_title(worksheet_name) end |