Sha256: 1b847d4f26bf6891cdb0e0beeb6f6cde47a8f2ad28eceec464161f505f14db12

Contents?: true

Size: 1.11 KB

Versions: 32

Compression:

Stored size: 1.11 KB

Contents

# frozen_string_literal: true

module OoxmlParser
  # Class for parsing `u` tags
  class Underline < OOXMLDocumentObject
    attr_accessor :style, :color

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

    # Compare this object to other
    # @param other [Object] any other object
    # @return [True, False] result of comparision
    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

    # @return [String] result of convert of object to string
    def to_s
      if @color.nil?
        @style.to_s
      else
        "#{@style} #{@color}"
      end
    end

    # Parse Underline object
    # @param node [Nokogiri::XML:Element] node to parse
    # @return [Underline] result of parsing
    def parse(node)
      case node
      when 'sng'
        @style = :single
      when 'none'
        @style = :none
      end
      self
    end
  end
end

Version data entries

32 entries across 32 versions & 1 rubygems

Version Path
ooxml_parser-0.33.0 lib/ooxml_parser/common_parser/common_data/underline.rb
ooxml_parser-0.32.0 lib/ooxml_parser/common_parser/common_data/underline.rb
ooxml_parser-0.31.0 lib/ooxml_parser/common_parser/common_data/underline.rb
ooxml_parser-0.30.0 lib/ooxml_parser/common_parser/common_data/underline.rb
ooxml_parser-0.29.0 lib/ooxml_parser/common_parser/common_data/underline.rb
ooxml_parser-0.28.0 lib/ooxml_parser/common_parser/common_data/underline.rb
ooxml_parser-0.27.0 lib/ooxml_parser/common_parser/common_data/underline.rb
ooxml_parser-0.26.0 lib/ooxml_parser/common_parser/common_data/underline.rb
ooxml_parser-0.25.0 lib/ooxml_parser/common_parser/common_data/underline.rb
ooxml_parser-0.24.0 lib/ooxml_parser/common_parser/common_data/underline.rb
ooxml_parser-0.23.0 lib/ooxml_parser/common_parser/common_data/underline.rb
ooxml_parser-0.22.0 lib/ooxml_parser/common_parser/common_data/underline.rb
ooxml_parser-0.21.0 lib/ooxml_parser/common_parser/common_data/underline.rb
ooxml_parser-0.20.0 lib/ooxml_parser/common_parser/common_data/underline.rb
ooxml_parser-0.19.0 lib/ooxml_parser/common_parser/common_data/underline.rb
ooxml_parser-0.18.1 lib/ooxml_parser/common_parser/common_data/underline.rb
ooxml_parser-0.18.0 lib/ooxml_parser/common_parser/common_data/underline.rb
ooxml_parser-0.17.0 lib/ooxml_parser/common_parser/common_data/underline.rb
ooxml_parser-0.16.0 lib/ooxml_parser/common_parser/common_data/underline.rb
ooxml_parser-0.15.0 lib/ooxml_parser/common_parser/common_data/underline.rb