Class: OOXML::Excel::Styles::Font

Inherits:
Object
  • Object
show all
Defined in:
lib/ooxml_excel/styles.rb

Instance Attribute Summary collapse

Class Method Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(**attrs) ⇒ Font

Returns a new instance of Font.



57
58
59
# File 'lib/ooxml_excel/styles.rb', line 57

def initialize(**attrs)
  attrs.each { |property, value| send("#{property}=", value)}
end

Instance Attribute Details

#boldObject Also known as: bold?

Returns the value of attribute bold.



55
56
57
# File 'lib/ooxml_excel/styles.rb', line 55

def bold
  @bold
end

#nameObject

Returns the value of attribute name.



55
56
57
# File 'lib/ooxml_excel/styles.rb', line 55

def name
  @name
end

#rgb_colorObject

Returns the value of attribute rgb_color.



55
56
57
# File 'lib/ooxml_excel/styles.rb', line 55

def rgb_color
  @rgb_color
end

#sizeObject

Returns the value of attribute size.



55
56
57
# File 'lib/ooxml_excel/styles.rb', line 55

def size
  @size
end

#themeObject

Returns the value of attribute theme.



55
56
57
# File 'lib/ooxml_excel/styles.rb', line 55

def theme
  @theme
end

Class Method Details

.load_from_node(font_node) ⇒ Object



60
61
62
63
64
65
66
67
68
69
70
71
72
# File 'lib/ooxml_excel/styles.rb', line 60

def self.load_from_node(font_node)
  font_size_node = font_node.at('sz')
  font_color_node = font_node.at('color')
  font_name_node = font_node.at('name')
  font_bold_node = font_node.at('b')
  self.new(
    size: font_size_node && font_size_node.attributes["val"].value,
    name: font_name_node && font_name_node.attributes["val"].value,
    rgb_color: font_color_node && font_color_node.attributes["rgb"].try(:value),
    theme: font_color_node && font_color_node.attributes["theme"].try(:value),
    bold: font_bold_node.present?
  )
end