Class: OoxmlParser::FontStyle

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

Overview

Class for working with font styles (bold,italic,underlined,strike)

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(bold = false, italic = false, underlined = Underline.new(:none), strike = :none) ⇒ FontStyle

Default constructor

Parameters:

  • bold (true, false) (defaults to: false)

    is bold?

  • italic (true, false) (defaults to: false)

    is italic?

  • underlined (true, false, String) (defaults to: Underline.new(:none))

    if not false or nil - default Underline, else none

  • strike (Symbol) (defaults to: :none)

    string with strike type



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

def initialize(bold = false, italic = false, underlined = Underline.new(:none), strike = :none)
  @bold = bold
  @italic = italic
  @underlined = underlined == false || underlined.nil? ? Underline.new(:none) : underlined
  @strike = strike
end

Instance Attribute Details

#boldfalse, true

Returns is bold?.

Returns:

  • (false, true)

    is bold?



9
10
11
# File 'lib/ooxml_parser/common_parser/common_data/font_style.rb', line 9

def bold
  @bold
end

#italicfalse, true

Returns is bold?.

Returns:

  • (false, true)

    is bold?



11
12
13
# File 'lib/ooxml_parser/common_parser/common_data/font_style.rb', line 11

def italic
  @italic
end

#strikeStrike

Returns strike type.

Returns:

  • (Strike)

    strike type



15
16
17
# File 'lib/ooxml_parser/common_parser/common_data/font_style.rb', line 15

def strike
  @strike
end

#underlinedUnderline

Returns underline type.

Returns:



13
14
15
# File 'lib/ooxml_parser/common_parser/common_data/font_style.rb', line 13

def underlined
  @underlined
end

Instance Method Details

#==(other) ⇒ true, false

Default == operator

Returns:

  • (true, false)

    true if two same, false if different



32
33
34
# File 'lib/ooxml_parser/common_parser/common_data/font_style.rb', line 32

def ==(other)
  (@bold == other.bold) && (@italic == other.italic) && (@underlined == other.underlined) && (@strike == other.strike)
end

#to_sString

Default to_s operator

Returns:

  • (String)

    with text representation



38
39
40
# File 'lib/ooxml_parser/common_parser/common_data/font_style.rb', line 38

def to_s
  "Bold: #{@bold}, Italic: #{@italic}, Underlined: #{@underlined}, Strike: #{@strike}"
end