Class: Parchment::Style

Inherits:
Object
  • Object
show all
Defined in:
lib/parchment/style.rb

Direct Known Subclasses

DOCX::Style, ODT::Style, TXT::Style

Constant Summary collapse

AVAILABLE_FORMATTING =
%w(
  bold
  italic
  underline
  aligned_left
  aligned_right
  aligned_center
)

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(node) ⇒ Style

This needs to be defined in each format’s subclass.



25
26
27
# File 'lib/parchment/style.rb', line 25

def initialize(node)
  raise MissingFormatterMethodError
end

Instance Attribute Details

#familyObject (readonly)

Returns the value of attribute family.



13
14
15
# File 'lib/parchment/style.rb', line 13

def family
  @family
end

#font_sizeObject (readonly)

Returns the value of attribute font_size.



13
14
15
# File 'lib/parchment/style.rb', line 13

def font_size
  @font_size
end

#font_styleObject (readonly)

Returns the value of attribute font_style.



13
14
15
# File 'lib/parchment/style.rb', line 13

def font_style
  @font_style
end

#font_weightObject (readonly)

Returns the value of attribute font_weight.



13
14
15
# File 'lib/parchment/style.rb', line 13

def font_weight
  @font_weight
end

#idObject (readonly)

Returns the value of attribute id.



13
14
15
# File 'lib/parchment/style.rb', line 13

def id
  @id
end

#nameObject (readonly)

Returns the value of attribute name.



13
14
15
# File 'lib/parchment/style.rb', line 13

def name
  @name
end

#parent_style_nameObject (readonly)

Returns the value of attribute parent_style_name.



13
14
15
# File 'lib/parchment/style.rb', line 13

def parent_style_name
  @parent_style_name
end

#text_alignObject (readonly)

Returns the value of attribute text_align.



13
14
15
# File 'lib/parchment/style.rb', line 13

def text_align
  @text_align
end

#text_underline_styleObject (readonly)

Returns the value of attribute text_underline_style.



13
14
15
# File 'lib/parchment/style.rb', line 13

def text_underline_style
  @text_underline_style
end

Instance Method Details

#aligned_center?Boolean

Returns:

  • (Boolean)


57
58
59
# File 'lib/parchment/style.rb', line 57

def aligned_center?
  @text_align == :center
end

#aligned_left?Boolean

Returns:

  • (Boolean)


49
50
51
# File 'lib/parchment/style.rb', line 49

def aligned_left?
  [:left, nil].include?(@text_align)
end

#aligned_right?Boolean

Returns:

  • (Boolean)


53
54
55
# File 'lib/parchment/style.rb', line 53

def aligned_right?
  @text_align == :right
end

#bold?Boolean

Returns:

  • (Boolean)


37
38
39
# File 'lib/parchment/style.rb', line 37

def bold?
  @font_weight == 'bold'
end

#italic?Boolean

Returns:

  • (Boolean)


41
42
43
# File 'lib/parchment/style.rb', line 41

def italic?
  @font_style == 'italic'
end

#paragraph?Boolean

Returns:

  • (Boolean)


29
30
31
# File 'lib/parchment/style.rb', line 29

def paragraph?
  @family == 'paragraph'
end

#text?Boolean

Returns:

  • (Boolean)


33
34
35
# File 'lib/parchment/style.rb', line 33

def text?
  @family == 'text'
end

#underline?Boolean

Returns:

  • (Boolean)


45
46
47
# File 'lib/parchment/style.rb', line 45

def underline?
  !@text_underline_style.nil?
end