Class: CSVPlusPlus::Modifier::GoogleSheetModifier
- Extended by:
- T::Sig
- Defined in:
- lib/csv_plus_plus/modifier/google_sheet_modifier.rb
Overview
Decorate a Modifier
so it is more compatible with the Google Sheets API
Instance Attribute Summary
Attributes inherited from Modifier
#bordercolor, #borders, #borderstyle, #color, #expand, #fontcolor, #fontfamily, #fontsize, #formats, #halign, #note, #numberformat, #row_level, #validate, #valign, #var
Instance Method Summary collapse
-
#background_color ⇒ Google::Apis::SheetsV4::Color
Format the color for Google Sheets.
-
#border ⇒ Google::Apis::SheetsV4::Border
Format the border for Google Sheets.
-
#font_color ⇒ Google::Apis::SheetsV4::Color
Format the fontcolor for Google Sheets.
-
#horizontal_alignment ⇒ ::String
Format the halign for Google Sheets.
-
#number_format ⇒ Google::Apis::SheetsV4::NumberFormat
Format the numberformat for Google Sheets.
-
#text_format ⇒ Google::Apis::SheetsV4::TextFormat
Builds a SheetsV4::TextFormat with the underlying Modifier.
-
#vertical_alignment ⇒ Object
Format the valign for Google Sheets.
Methods inherited from Modifier
#any_border?, #border=, #border_all?, #border_along?, #cell_level?, #format=, #formatted?, #freeze!, #frozen?, #infinite_expand!, #initialize, #row_level!, #row_level?, #take_defaults_from!
Constructor Details
This class inherits a constructor from CSVPlusPlus::Modifier::Modifier
Instance Method Details
#background_color ⇒ Google::Apis::SheetsV4::Color
Format the color for Google Sheets
14 15 16 |
# File 'lib/csv_plus_plus/modifier/google_sheet_modifier.rb', line 14 def background_color google_sheets_color(@color) if @color end |
#border ⇒ Google::Apis::SheetsV4::Border
Format the border for Google Sheets
22 23 24 25 26 27 28 29 30 |
# File 'lib/csv_plus_plus/modifier/google_sheet_modifier.rb', line 22 def border return unless any_border? # TODO: allow different border styles per side? ::Google::Apis::SheetsV4::Border.new( color: google_sheets_color(bordercolor || ::CSVPlusPlus::Color.new('#000000')), style: border_style ) end |
#font_color ⇒ Google::Apis::SheetsV4::Color
Format the fontcolor for Google Sheets
36 37 38 |
# File 'lib/csv_plus_plus/modifier/google_sheet_modifier.rb', line 36 def font_color google_sheets_color(@fontcolor) if @fontcolor end |
#horizontal_alignment ⇒ ::String
Format the halign for Google Sheets
44 45 46 |
# File 'lib/csv_plus_plus/modifier/google_sheet_modifier.rb', line 44 def horizontal_alignment halign&.serialize&.upcase end |
#number_format ⇒ Google::Apis::SheetsV4::NumberFormat
Format the numberformat for Google Sheets
53 54 55 |
# File 'lib/csv_plus_plus/modifier/google_sheet_modifier.rb', line 53 def number_format ::Google::Apis::SheetsV4::NumberFormat.new(type: number_format_type(@numberformat)) if @numberformat end |
#text_format ⇒ Google::Apis::SheetsV4::TextFormat
Builds a SheetsV4::TextFormat with the underlying Modifier
61 62 63 64 65 66 67 68 69 70 71 |
# File 'lib/csv_plus_plus/modifier/google_sheet_modifier.rb', line 61 def text_format ::Google::Apis::SheetsV4::TextFormat.new( bold: formatted?(::CSVPlusPlus::Modifier::TextFormat::Bold) || nil, italic: formatted?(::CSVPlusPlus::Modifier::TextFormat::Italic) || nil, strikethrough: formatted?(::CSVPlusPlus::Modifier::TextFormat::Strikethrough) || nil, underline: formatted?(::CSVPlusPlus::Modifier::TextFormat::Underline) || nil, font_family: fontfamily, font_size: fontsize, foreground_color: font_color ) end |
#vertical_alignment ⇒ Object
Format the valign for Google Sheets
75 76 77 |
# File 'lib/csv_plus_plus/modifier/google_sheet_modifier.rb', line 75 def vertical_alignment valign&.serialize&.upcase end |