Class: OOXL::Font

Inherits:
Object
  • Object
show all
Defined in:
lib/ooxl/xl_objects/font.rb

Instance Attribute Summary collapse

Class Method Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(**attrs) ⇒ Font

Returns a new instance of Font.



5
6
7
# File 'lib/ooxl/xl_objects/font.rb', line 5

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.



3
4
5
# File 'lib/ooxl/xl_objects/font.rb', line 3

def bold
  @bold
end

#color_indexObject

Returns the value of attribute color_index.



3
4
5
# File 'lib/ooxl/xl_objects/font.rb', line 3

def color_index
  @color_index
end

#nameObject

Returns the value of attribute name.



3
4
5
# File 'lib/ooxl/xl_objects/font.rb', line 3

def name
  @name
end

#rgb_colorObject

Returns the value of attribute rgb_color.



3
4
5
# File 'lib/ooxl/xl_objects/font.rb', line 3

def rgb_color
  @rgb_color
end

#sizeObject

Returns the value of attribute size.



3
4
5
# File 'lib/ooxl/xl_objects/font.rb', line 3

def size
  @size
end

#themeObject

Returns the value of attribute theme.



3
4
5
# File 'lib/ooxl/xl_objects/font.rb', line 3

def theme
  @theme
end

Class Method Details

.load_from_node(font_node) ⇒ Object



8
9
10
11
12
13
14
15
16
17
18
19
20
21
# File 'lib/ooxl/xl_objects/font.rb', line 8

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) ,
    color_index: font_color_node && font_color_node.attributes["indexed"].try(:value),
    theme: font_color_node && font_color_node.attributes["theme"].try(:value),
    bold: font_bold_node.present?,
  )
end