Class: OoxmlParser::FontStyle

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

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



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

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?



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

def bold
  @bold
end

#italicfalse, true

Returns is bold?.

Returns:

  • (false, true)

    is bold?



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

def italic
  @italic
end

#strikeStrike

Returns strike type.

Returns:

  • (Strike)

    strike type



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

def strike
  @strike
end

#underlinedUnderline

Returns underline type.

Returns:



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

def underlined
  @underlined
end

Instance Method Details

#==(other) ⇒ true, false

Default == operator

Returns:

  • (true, false)

    true if two same, false if different



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

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



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

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