Class: OoxmlParser::OOXMLFont
- Inherits:
-
OOXMLDocumentObject
- Object
- OOXMLDocumentObject
- OoxmlParser::OOXMLFont
- Defined in:
- lib/ooxml_parser/xlsx_parser/xlsx_data/view_model/workbook/worksheet/xlsx_row/xlsx_cell/cell_style/ooxml_font.rb
Constant Summary
Constants inherited from OOXMLDocumentObject
OoxmlParser::OOXMLDocumentObject::DEFAULT_DIRECTORY_FOR_MEDIA
Instance Attribute Summary collapse
-
#color ⇒ Object
Returns the value of attribute color.
-
#font_style ⇒ Object
Returns the value of attribute font_style.
-
#name ⇒ Object
Returns the value of attribute name.
-
#size ⇒ Object
Returns the value of attribute size.
Class Method Summary collapse
Instance Method Summary collapse
-
#initialize(name = 'Calibri', size = '11', font_style = nil, color = nil) ⇒ OOXMLFont
constructor
A new instance of OOXMLFont.
Methods inherited from OOXMLDocumentObject
#==, add_to_xmls_stack, copy_file_and_rename_to_zip, copy_media_file, current_xml, dir, encrypted_file?, get_link_from_rels, media_folder, option_enabled?, unzip_file
Constructor Details
#initialize(name = 'Calibri', size = '11', font_style = nil, color = nil) ⇒ OOXMLFont
Returns a new instance of OOXMLFont.
6 7 8 9 10 11 |
# File 'lib/ooxml_parser/xlsx_parser/xlsx_data/view_model/workbook/worksheet/xlsx_row/xlsx_cell/cell_style/ooxml_font.rb', line 6 def initialize(name = 'Calibri', size = '11', font_style = nil, color = nil) @name = name @size = size @font_style = font_style @color = color end |
Instance Attribute Details
#color ⇒ Object
Returns the value of attribute color.
4 5 6 |
# File 'lib/ooxml_parser/xlsx_parser/xlsx_data/view_model/workbook/worksheet/xlsx_row/xlsx_cell/cell_style/ooxml_font.rb', line 4 def color @color end |
#font_style ⇒ Object
Returns the value of attribute font_style.
4 5 6 |
# File 'lib/ooxml_parser/xlsx_parser/xlsx_data/view_model/workbook/worksheet/xlsx_row/xlsx_cell/cell_style/ooxml_font.rb', line 4 def font_style @font_style end |
#name ⇒ Object
Returns the value of attribute name.
4 5 6 |
# File 'lib/ooxml_parser/xlsx_parser/xlsx_data/view_model/workbook/worksheet/xlsx_row/xlsx_cell/cell_style/ooxml_font.rb', line 4 def name @name end |
#size ⇒ Object
Returns the value of attribute size.
4 5 6 |
# File 'lib/ooxml_parser/xlsx_parser/xlsx_data/view_model/workbook/worksheet/xlsx_row/xlsx_cell/cell_style/ooxml_font.rb', line 4 def size @size end |
Class Method Details
.parse(style_number) ⇒ Object
13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 |
# File 'lib/ooxml_parser/xlsx_parser/xlsx_data/view_model/workbook/worksheet/xlsx_row/xlsx_cell/cell_style/ooxml_font.rb', line 13 def self.parse(style_number) font = OOXMLFont.new font_style_node = XLSXWorkbook.styles_node.xpath('//xmlns:font')[style_number.to_i] font.name = font_style_node.xpath('xmlns:name').first.attribute('val').value if font_style_node.xpath('xmlns:name').first font.size = font_style_node.xpath('xmlns:sz').first.attribute('val').value.to_i if font_style_node.xpath('xmlns:sz').first font.font_style = FontStyle.new font_style_node.xpath('*').each do |font_style_node_child| case font_style_node_child.name when 'b' font.font_style.bold = true when 'i' font.font_style.italic = true when 'strike' font.font_style.strike = :single when 'u' font.font_style.underlined = Underline.new(:single) when 'color' font.color = Color.parse_color_tag(font_style_node_child) end end font end |