Class: OoxmlParser::Underline
- Inherits:
-
OOXMLDocumentObject
- Object
- OOXMLDocumentObject
- OoxmlParser::Underline
- Defined in:
- lib/ooxml_parser/common_parser/common_data/underline.rb
Overview
Class for parsing ‘u` tags
Instance Attribute Summary collapse
-
#color ⇒ Color
Color of underline.
-
#style ⇒ Object
Returns the value of attribute style.
-
#value ⇒ Symbol
readonly
Value of underline.
Attributes inherited from OOXMLDocumentObject
Instance Method Summary collapse
-
#==(other) ⇒ True, False
Compare this object to other.
-
#initialize(style = :none, color = nil, parent: nil) ⇒ Underline
constructor
A new instance of Underline.
-
#parse(node) ⇒ Underline
Parse Underline object.
-
#to_s ⇒ String
Result of convert of object to string.
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(style = :none, color = nil, parent: nil) ⇒ Underline
Returns a new instance of Underline.
12 13 14 15 16 |
# File 'lib/ooxml_parser/common_parser/common_data/underline.rb', line 12 def initialize(style = :none, color = nil, parent: nil) @style = style == 'single' ? :single : style @color = color super(parent: parent) end |
Instance Attribute Details
#color ⇒ Color
Returns color of underline.
8 9 10 |
# File 'lib/ooxml_parser/common_parser/common_data/underline.rb', line 8 def color @color end |
#style ⇒ Object
Returns the value of attribute style.
6 7 8 |
# File 'lib/ooxml_parser/common_parser/common_data/underline.rb', line 6 def style @style end |
#value ⇒ Symbol (readonly)
Returns value of underline.
10 11 12 |
# File 'lib/ooxml_parser/common_parser/common_data/underline.rb', line 10 def value @value end |
Instance Method Details
#==(other) ⇒ True, False
Compare this object to other
21 22 23 24 25 26 27 28 29 30 |
# File 'lib/ooxml_parser/common_parser/common_data/underline.rb', line 21 def ==(other) case other when Underline @style.to_sym == other.style.to_sym && @color == other.color when Symbol @style.to_sym == other else false end end |
#parse(node) ⇒ Underline
Parse Underline object
44 45 46 47 48 49 50 51 52 53 54 |
# File 'lib/ooxml_parser/common_parser/common_data/underline.rb', line 44 def parse(node) parse_attributes(node) if node.is_a?(Nokogiri::XML::Element) case node when 'sng' @style = :single when 'none' @style = :none end self end |
#to_s ⇒ String
Returns result of convert of object to string.
33 34 35 36 37 38 39 |
# File 'lib/ooxml_parser/common_parser/common_data/underline.rb', line 33 def to_s if @color.nil? @style.to_s else "#{@style} #{@color}" end end |