class BerkeleyLibrary::Util::ODS::XML::Style::CellStyle

Attributes

color[R]
font_weight[R]

Public Class Methods

new(name, protected = false, color = nil, styles:, font_weight: nil, wrap: false) click to toggle source

Initializes a new cell style. Note that this should not be called directly, but only from {XML::Office::AutomaticStyles#add_cell_style}.

@param name [String] the style name @param color [String, nil] a hex color (e.g. `#fdb515`) @param font_weight [String, nil] the font weight, if other than normal @param wrap [Boolean] whether to allow text wrapping @param styles [XML::Office::AutomaticStyles] the document styles rubocop:disable Metrics/ParameterLists, Style/OptionalBooleanParameter

Calls superclass method
# File lib/berkeley_library/util/ods/xml/style/cell_style.rb, line 23
def initialize(name, protected = false, color = nil, styles:, font_weight: nil, wrap: false)
  super(name, :table_cell, doc: styles.doc)
  @protected = protected
  @color = color
  @font_weight = font_weight
  @wrap = wrap

  set_attribute('parent-style-name', 'Default')
  add_default_children!
end

Public Instance Methods

custom_text_properties?() click to toggle source
# File lib/berkeley_library/util/ods/xml/style/cell_style.rb, line 43
def custom_text_properties?
  [color, font_weight].any? { |p| !p.nil? }
end
protected?() click to toggle source

rubocop:enable Metrics/ParameterLists, Style/OptionalBooleanParameter

# File lib/berkeley_library/util/ods/xml/style/cell_style.rb, line 35
def protected?
  @protected
end
wrap?() click to toggle source
# File lib/berkeley_library/util/ods/xml/style/cell_style.rb, line 39
def wrap?
  @wrap
end

Private Instance Methods

add_default_children!() click to toggle source
# File lib/berkeley_library/util/ods/xml/style/cell_style.rb, line 49
def add_default_children!
  children << TableCellProperties.new(protected?, wrap: wrap?, doc: doc)
  children << TextProperties.new(color: color, font_weight: font_weight, doc: doc) if custom_text_properties?
end