Class: OoxmlParser::Underline

Inherits:
OOXMLDocumentObject show all
Defined in:
lib/ooxml_parser/common_parser/common_data/underline.rb

Overview

Class for parsing u tags

Instance Attribute Summary collapse

Attributes inherited from OOXMLDocumentObject

#parent

Instance Method Summary collapse

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

#to_hash

Constructor Details

#initialize(style = :none, color = nil, parent: nil) ⇒ Underline

Returns a new instance of Underline.



6
7
8
9
10
# File 'lib/ooxml_parser/common_parser/common_data/underline.rb', line 6

def initialize(style = :none, color = nil, parent: nil)
  @style = style == 'single' ? :single : style
  @color = color
  @parent = parent
end

Instance Attribute Details

#colorObject

Returns the value of attribute color.



4
5
6
# File 'lib/ooxml_parser/common_parser/common_data/underline.rb', line 4

def color
  @color
end

#styleObject

Returns the value of attribute style.



4
5
6
# File 'lib/ooxml_parser/common_parser/common_data/underline.rb', line 4

def style
  @style
end

Instance Method Details

#==(other) ⇒ Object



12
13
14
15
16
17
18
19
20
# File 'lib/ooxml_parser/common_parser/common_data/underline.rb', line 12

def ==(other)
  if other.is_a? Underline
    @style.to_sym == other.style.to_sym && @color == other.color
  elsif other.is_a? Symbol
    @style.to_sym == other
  else
    false
  end
end

#parse(node) ⇒ Underline

Parse Underline object

Parameters:

  • node (Nokogiri::XML:Element)

    node to parse

Returns:



33
34
35
36
37
38
39
40
41
# File 'lib/ooxml_parser/common_parser/common_data/underline.rb', line 33

def parse(node)
  case node
  when 'sng'
    @style = :single
  when 'none'
    @style = :none
  end
  self
end

#to_sObject



22
23
24
25
26
27
28
# File 'lib/ooxml_parser/common_parser/common_data/underline.rb', line 22

def to_s
  if @color.nil?
    @style.to_s
  else
    "#{@style} #{@color}"
  end
end