Class: CSVPlusPlus::Writer::GoogleSheetModifier

Inherits:
SimpleDelegator
  • Object
show all
Defined in:
lib/csv_plus_plus/writer/google_sheet_modifier.rb

Overview

Decorate a Modifier so it can be written to the Google Sheets API

Instance Method Summary collapse

Instance Method Details

#borderGoogle::Apis::SheetsV4::Border

Format the border for Google Sheets

Returns:

  • (Google::Apis::SheetsV4::Border)


10
11
12
13
14
15
16
# File 'lib/csv_plus_plus/writer/google_sheet_modifier.rb', line 10

def border
  # TODO: allow different border styles per side
  ::Google::Apis::SheetsV4::Border.new(
    color: bordercolor&.to_s || '#000000',
    style: borderstyle&.to_s || 'solid'
  )
end

#colorGoogle::Apis::SheetsV4::Color

Format the color for Google Sheets

Returns:

  • (Google::Apis::SheetsV4::Color)


21
22
23
# File 'lib/csv_plus_plus/writer/google_sheet_modifier.rb', line 21

def color
  google_sheets_color(super) if super
end

#fontcolorGoogle::Apis::SheetsV4::Color

Format the fontcolor for Google Sheets

Returns:

  • (Google::Apis::SheetsV4::Color)


28
29
30
# File 'lib/csv_plus_plus/writer/google_sheet_modifier.rb', line 28

def fontcolor
  google_sheets_color(super) if super
end

#halignString

Format the halign for Google Sheets

Returns:

  • (String)


35
36
37
# File 'lib/csv_plus_plus/writer/google_sheet_modifier.rb', line 35

def halign
  super&.to_s&.upcase
end

#numberformat::Google::Apis::SheetsV4::NumberFormat

Format the numberformat for Google Sheets

Returns:

  • (::Google::Apis::SheetsV4::NumberFormat)


42
43
44
# File 'lib/csv_plus_plus/writer/google_sheet_modifier.rb', line 42

def numberformat
  ::Google::Apis::SheetsV4::NumberFormat.new(type: super) if super
end

#text_format::Google::Apis::SheetsV4::TextFormat

Builds a SheetsV4::TextFormat with the underlying Modifier

Returns:

  • (::Google::Apis::SheetsV4::TextFormat)


49
50
51
52
53
54
55
56
57
58
59
# File 'lib/csv_plus_plus/writer/google_sheet_modifier.rb', line 49

def text_format
  ::Google::Apis::SheetsV4::TextFormat.new(
    bold: formatted?(:bold) || nil,
    italic: formatted?(:italic) || nil,
    strikethrough: formatted?(:strikethrough) || nil,
    underline: formatted?(:underline) || nil,
    font_family: fontfamily,
    font_size: fontsize,
    foreground_color: fontcolor
  )
end

#valignObject

Format the valign for Google Sheets



62
63
64
# File 'lib/csv_plus_plus/writer/google_sheet_modifier.rb', line 62

def valign
  super&.to_s&.upcase
end