You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: lib/docx/document.rb
+13-9Lines changed: 13 additions & 9 deletions
Original file line number
Diff line number
Diff line change
@@ -4,13 +4,13 @@
4
4
moduleDocx
5
5
# The Document class wraps around a docx file and provides methods to
6
6
# interface with it.
7
-
#
7
+
#
8
8
# # get a Docx::Document for a docx file in the local directory
9
9
# doc = Docx::Document.open("test.docx")
10
-
#
10
+
#
11
11
# # get the text from the document
12
12
# puts doc.text
13
-
#
13
+
#
14
14
# # do the same thing in a block
15
15
# Docx::Document.open("test.docx") do |d|
16
16
# puts d.text
@@ -26,7 +26,7 @@ def initialize(path, &block)
26
26
@parser=Parser.new(File.expand_path(path))
27
27
end
28
28
end
29
-
29
+
30
30
# With no associated block, Docx::Document.open is a synonym for Docx::Document.new. If the optional code block is given, it will be passed the opened +docx+ file as an argument and the Docx::Document oject will automatically be closed when the block terminates. The values of the block will be returned from Docx::Document.open.
31
31
# call-seq:
32
32
# open(filepath) => file
@@ -37,14 +37,14 @@ def self.open(path, &block)
37
37
38
38
##
39
39
# *Deprecated*
40
-
#
40
+
#
41
41
# Iterates over paragraphs within document
42
42
# call-seq:
43
43
# each_paragraph => Enumerator
44
44
defeach_paragraph
45
45
paragraphs.each{ |p| yield(p)}
46
46
end
47
-
47
+
48
48
# call-seq:
49
49
# to_s -> string
50
50
defto_s
@@ -69,18 +69,22 @@ def save(path)
69
69
end
70
70
zip.close
71
71
end
72
-
72
+
73
73
alias_method:text,:to_s
74
74
75
+
defreplace_entry(entry_path,file_contents)
76
+
@replace[entry_path]=file_contents
77
+
end
78
+
75
79
private
76
80
77
81
#--
78
82
# TODO: Flesh this out to be compatible with other files
79
-
# TODO: Method to set flag on files that have been edited, probably by inserting something at the
83
+
# TODO: Method to set flag on files that have been edited, probably by inserting something at the
0 commit comments