Class: RubyDocx::Elements::TableStyle
- Inherits:
-
Element
- Object
- Element
- RubyDocx::Elements::TableStyle
show all
- Defined in:
- lib/ruby_docx/elements/table_style.rb
Instance Attribute Summary
Attributes inherited from Element
#doc, #grid, #node, #style
Instance Method Summary
collapse
Methods inherited from Element
#elements, #initialize, #inspect, #to_xml
Instance Method Details
#align ⇒ Object
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
|
# File 'lib/ruby_docx/elements/table_style.rb', line 22
def align
ele = @node.xpath(".//w:jc").last
if ele
v = ele.attributes["val"].value.to_s
if v == "start"
"left"
elsif v == "end"
"right"
elsif v == "center"
"center"
end
else
nil
end
end
|
#bold? ⇒ Boolean
39
40
41
|
# File 'lib/ruby_docx/elements/table_style.rb', line 39
def bold?
false
end
|
#color ⇒ Object
63
64
65
66
67
68
69
70
71
72
73
74
75
76
|
# File 'lib/ruby_docx/elements/table_style.rb', line 63
def color
ele = @node.xpath(".//w:color").last
if ele
v = ele.attributes["val"].value
if v.to_s == "auto"
nil
else
v
end
else
nil
end
end
|
#font_name ⇒ Object
78
79
80
81
82
83
84
85
86
87
88
89
90
|
# File 'lib/ruby_docx/elements/table_style.rb', line 78
def font_name
ele = @node.xpath(".//w:rFonts").last
if ele
ascii = ele.attributes["ascii"]
cs = ele.attributes["cs"]
hAnsi = ele.attributes["hAnsi"]
ascii.value
else
nil
end
end
|
#font_size ⇒ Object
43
44
45
46
47
48
49
50
51
52
53
|
# File 'lib/ruby_docx/elements/table_style.rb', line 43
def font_size
ele = @node.xpath(".//w:sz").last
if ele
v = ele.attributes["val"].value
v.to_i/2
else
nil
end
end
|
#fonts ⇒ Object
93
94
95
96
97
98
99
100
101
102
103
104
105
|
# File 'lib/ruby_docx/elements/table_style.rb', line 93
def fonts
ele = @node.xpath(".//w:rFonts").last
if ele
ascii = ele.attributes["ascii"]
cs = ele.attributes["cs"]
hAnsi = ele.attributes["hAnsi"]
[ascii.value, cs.value, hAnsi.value].uniq
else
nil
end
end
|
#height ⇒ Object
59
60
61
|
# File 'lib/ruby_docx/elements/table_style.rb', line 59
def height
nil
end
|
#to_s ⇒ Object
attr_reader :font_name, :font_size, :color, :text_align, :fonts
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
|
# File 'lib/ruby_docx/elements/table_style.rb', line 5
def to_s
arry = []
if font_size
arry << "font-size: #{font_size}pt"
end
if fonts
arry << "font-family: #{fonts.join(",")}"
end
if color
arry << "color: #{color}"
end
arry.join(";")
end
|
#width ⇒ Object
55
56
57
|
# File 'lib/ruby_docx/elements/table_style.rb', line 55
def width
nil
end
|