Class: Munchsrb::Exporter::Sheet
- Inherits:
-
Object
- Object
- Munchsrb::Exporter::Sheet
- Defined in:
- lib/munchsrb/exporter/sheet.rb
Overview
Munchsrb::Exporter::Sheet exports content to Google Spread Sheet.
Constant Summary collapse
- HEADER =
%w[メニュー名 金額].freeze
- ROW_START_INDEX =
1- COLUMN_START_INDEX =
1
Instance Method Summary collapse
- #export(details) ⇒ Object
-
#initialize(key = nil) ⇒ Sheet
constructor
A new instance of Sheet.
Constructor Details
#initialize(key = nil) ⇒ Sheet
Returns a new instance of Sheet.
11 12 13 14 |
# File 'lib/munchsrb/exporter/sheet.rb', line 11 def initialize(key = nil) session = Munchsrb::Exporter::GoogleClient.session @worksheet = session.spreadsheet_by_key(ENV.fetch('GOOGLE_SPREAD_SHEET_KEY', key)).worksheets[0] end |
Instance Method Details
#export(details) ⇒ Object
16 17 18 19 20 21 |
# File 'lib/munchsrb/exporter/sheet.rb', line 16 def export(details) contents = [] contents << HEADER details.each { |detail| contents << [detail[:name], detail[:price]] } save(contents) end |