Class: OoxmlParser::Font
- Inherits:
-
OOXMLDocumentObject
- Object
- OOXMLDocumentObject
- OoxmlParser::Font
- Defined in:
- lib/ooxml_parser/xlsx_parser/xlsx_data/view_model/workbook/style_sheet/fonts/font.rb
Overview
Parsing fonts tag
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.
-
#vertical_alignment ⇒ ValuedChild
readonly
Vertical alignment of font.
Attributes inherited from OOXMLDocumentObject
Instance Method Summary collapse
-
#initialize(parent: nil) ⇒ Font
constructor
A new instance of Font.
- #parse(node) ⇒ Object
Methods inherited from OOXMLDocumentObject
#==, add_to_xmls_stack, copy_file_and_rename_to_zip, current_xml, dir, encrypted_file?, get_link_from_rels, unzip_file, #with_data?
Methods included from OoxmlDocumentObjectHelper
Constructor Details
#initialize(parent: nil) ⇒ Font
Returns a new instance of Font.
8 9 10 11 12 |
# File 'lib/ooxml_parser/xlsx_parser/xlsx_data/view_model/workbook/style_sheet/fonts/font.rb', line 8 def initialize(parent: nil) @name = 'Calibri' @size = 11 @parent = parent 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/style_sheet/fonts/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/style_sheet/fonts/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/style_sheet/fonts/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/style_sheet/fonts/font.rb', line 4 def size @size end |
#vertical_alignment ⇒ ValuedChild (readonly)
Returns vertical alignment of font.
6 7 8 |
# File 'lib/ooxml_parser/xlsx_parser/xlsx_data/view_model/workbook/style_sheet/fonts/font.rb', line 6 def vertical_alignment @vertical_alignment end |
Instance Method Details
#parse(node) ⇒ Object
14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 |
# File 'lib/ooxml_parser/xlsx_parser/xlsx_data/view_model/workbook/style_sheet/fonts/font.rb', line 14 def parse(node) @font_style = FontStyle.new node.xpath('*').each do |node_child| case node_child.name when 'name' @name = node_child.attribute('val').value when 'sz' @size = node_child.attribute('val').value.to_f when 'b' @font_style.bold = true when 'i' @font_style.italic = true when 'strike' @font_style.strike = :single when 'u' @font_style.underlined = Underline.new(:single) when 'color' @color = OoxmlColor.new(parent: self).parse(node_child) when 'vertAlign' @vertical_alignment = ValuedChild.new(:symbol, parent: self).parse(node_child) end end self end |