Class: OoxmlParser::Underline

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

Instance Attribute Summary collapse

Class Method Summary collapse

Instance Method Summary collapse

Constructor Details

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

Returns a new instance of Underline.



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

def initialize(style = :none, color = nil)
  @style = (style == 'single') ? :single : style
  @color = color
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

Class Method Details

.parse(attribute_value) ⇒ Object



29
30
31
32
33
34
35
36
37
38
# File 'lib/ooxml_parser/common_parser/common_data/underline.rb', line 29

def self.parse(attribute_value)
  underline = Underline.new
  case attribute_value
  when 'sng'
    underline.style = :single
  when 'none'
    underline.style = :none
  end
  underline
end

Instance Method Details

#==(other) ⇒ Object



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

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

#to_sObject



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

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