Class: OoxmlParser::Font
- Inherits:
-
OOXMLDocumentObject
- Object
- OOXMLDocumentObject
- OoxmlParser::Font
- Defined in:
- lib/ooxml_parser/xlsx_parser/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) ⇒ Font
Parse Font object.
Methods inherited from OOXMLDocumentObject
#==, #boolean_attribute_value, #parse_xml, #with_data?
Methods included from OoxmlObjectAttributeHelper
#attribute_enabled?, #option_enabled?
Methods included from OoxmlDocumentObjectHelper
Constructor Details
#initialize(parent: nil) ⇒ Font
Returns a new instance of Font.
10 11 12 13 14 |
# File 'lib/ooxml_parser/xlsx_parser/workbook/style_sheet/fonts/font.rb', line 10 def initialize(parent: nil) @name = 'Calibri' @size = 11 super end |
Instance Attribute Details
#color ⇒ Object
Returns the value of attribute color.
6 7 8 |
# File 'lib/ooxml_parser/xlsx_parser/workbook/style_sheet/fonts/font.rb', line 6 def color @color end |
#font_style ⇒ Object
Returns the value of attribute font_style.
6 7 8 |
# File 'lib/ooxml_parser/xlsx_parser/workbook/style_sheet/fonts/font.rb', line 6 def font_style @font_style end |
#name ⇒ Object
Returns the value of attribute name.
6 7 8 |
# File 'lib/ooxml_parser/xlsx_parser/workbook/style_sheet/fonts/font.rb', line 6 def name @name end |
#size ⇒ Object
Returns the value of attribute size.
6 7 8 |
# File 'lib/ooxml_parser/xlsx_parser/workbook/style_sheet/fonts/font.rb', line 6 def size @size end |
#vertical_alignment ⇒ ValuedChild (readonly)
Returns vertical alignment of font.
8 9 10 |
# File 'lib/ooxml_parser/xlsx_parser/workbook/style_sheet/fonts/font.rb', line 8 def vertical_alignment @vertical_alignment end |
Instance Method Details
#parse(node) ⇒ Font
Parse Font object
19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 |
# File 'lib/ooxml_parser/xlsx_parser/workbook/style_sheet/fonts/font.rb', line 19 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 |