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.



51
52
53
# File 'lib/ooxml_excel/styles.rb', line 51

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.



49
50
51
# File 'lib/ooxml_excel/styles.rb', line 49

def bold
  @bold
end

#nameObject

Returns the value of attribute name.



49
50
51
# File 'lib/ooxml_excel/styles.rb', line 49

def name
  @name
end

#rgb_colorObject

Returns the value of attribute rgb_color.



49
50
51
# File 'lib/ooxml_excel/styles.rb', line 49

def rgb_color
  @rgb_color
end

#sizeObject

Returns the value of attribute size.



49
50
51
# File 'lib/ooxml_excel/styles.rb', line 49

def size
  @size
end

#themeObject

Returns the value of attribute theme.



49
50
51
# File 'lib/ooxml_excel/styles.rb', line 49

def theme
  @theme
end

Class Method Details

.load_from_node(font_node) ⇒ Object



54
55
56
57
58
59
60
61
62
63
64
65
66
# File 'lib/ooxml_excel/styles.rb', line 54

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.attributes["val"].value,
    name: font_name_node.attributes["val"].value,
    rgb_color: (font_color_node.present?) ? font_color_node.attributes["rgb"].try(:value) : nil,
    theme: (font_color_node.present?) ? font_color_node.attributes["theme"].try(:value) : nil,
    bold: font_bold_node.present?
  )
end