Class: RVGP::Plot::GoogleDrive::Sheet

Inherits:
Object
  • Object
show all
Defined in:
lib/rvgp/plot/google-drive/sheet.rb

Overview

This class represents a csv-like matrix, that is to be sent to google, as a sheet in an exported workbook. There’s not much logic here.

Constant Summary collapse

MAX_COLUMNS =

This is the maximum number of columns that we support, in our sheets. This number is mostly here because Google stipulates this restriction

26

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(title, grid, options = {}) ⇒ Sheet

A sheet, and its options.

Parameters:

  • title (String)

    The title of this sheet

  • grid (Array<Array<Object>>)

    The data contents of this sheet

  • options (Hash) (defaults to: {})

    The parameters governing this Sheet

Options Hash (options):

  • :default_series_type (String)

    This parameter is sent to google’s addChart method. Expected to be either “COLUMN” or “LINE”.

  • :chart_type (String) — default: 'LINE'

    This parameter determines the kind plot that is built. Expected to be one of: “area”, or “column_and_lines”

  • :stacked_type (String)

    This parameter is sent to google’s addChart method. Expected to be either “STACKED” or nil.

  • :series_colors (Hash<String,String>)

    A Hash, indexed under the name of a series, whose value is set to the intended html rgb color of that series.

  • :series_types (Hash<String,String>)

    A Hash, indexed under the name of a series, whose value is set to either “COLUMN” or “LINE”. This setting allows you to override the :default_series_type, for a specific series.

  • :series_line_styles (Hash<String,String>)

    A Hash, indexed under the name of a series, whose value is set to either “dashed” or nil. This setting allows you to dash a series on the resulting plot.

  • :series_target_axis (Symbol) — default: :left

    Either :bottom, :left, or :right. This parameter is sent to google’s addChart method, to determine the ‘targetAxis’ of the plot.



40
41
42
43
44
45
46
47
48
49
50
51
# File 'lib/rvgp/plot/google-drive/sheet.rb', line 40

def initialize(title, grid, options = {})
  @title = title
  @options = options
  @grid = grid

  # This is a Google constraint:
  if columns.length > MAX_COLUMNS
    raise StandardError, format('Too many columns. Max is %<max>d, provided %<provided>d.',
                                max: MAX_COLUMNS,
                                provided: columns.length)
  end
end

Instance Attribute Details

#optionsHash

The options configured on this sheet

Returns:

  • (Hash)

    the current value of options



10
11
12
# File 'lib/rvgp/plot/google-drive/sheet.rb', line 10

def options
  @options
end

#titlestring

The title of this sheet

Returns:

  • (string)

    the current value of title



10
11
12
# File 'lib/rvgp/plot/google-drive/sheet.rb', line 10

def title
  @title
end

Instance Method Details

#columnsArray<Object>

The column titles for this spreadsheet, as calculated from the provided data.

Returns:

  • (Array<Object>)


55
56
57
# File 'lib/rvgp/plot/google-drive/sheet.rb', line 55

def columns
  @grid[0]
end

#rowsArray<Object>

The rows values for this spreadsheet, as calculated from the provided data.

Returns:

  • (Array<Object>)


61
62
63
# File 'lib/rvgp/plot/google-drive/sheet.rb', line 61

def rows
  @grid[1...]
end