Skip to content

Commit 1df69d8

Browse files
committed
Fixed the 'already initialized constant TAG' warning by converting to class level methods
1 parent 175c23d commit 1df69d8

5 files changed

Lines changed: 16 additions & 5 deletions

File tree

lib/docx/containers/paragraph.rb

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,10 @@ class Paragraph
88
include Container
99
include Elements::Element
1010

11-
TAG = 'p'
11+
def self.tag
12+
'p'
13+
end
14+
1215

1316
# Child elements: pPr, r, fldSimple, hlink, subDoc
1417
# http://msdn.microsoft.com/en-us/library/office/ee364458(v=office.11).aspx

lib/docx/containers/text_run.rb

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,9 @@ class TextRun
1313
underline: false
1414
}
1515

16-
TAG = 'r'
16+
def self.tag
17+
'r'
18+
end
1719

1820
attr_reader :text
1921
attr_reader :formatting

lib/docx/elements/bookmark.rb

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,9 @@ class Bookmark
66
include Element
77
attr_accessor :name
88

9-
TAG = 'bookmarkStart'
9+
def self.tag
10+
'bookmarkStart'
11+
end
1012

1113
def initialize(node)
1214
@node = node

lib/docx/elements/element.rb

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -58,7 +58,7 @@ def copy
5858
module ClassMethods
5959
def create_with(element)
6060
# Need to somehow get the xml document accessible here by default, but this is alright in the interim
61-
self.new(Nokogiri::XML::Node.new("w:#{self.const_get(:TAG)}", element.node))
61+
self.new(Nokogiri::XML::Node.new("w:#{self.tag}", element.node))
6262
end
6363

6464
def create_within(element)

lib/docx/elements/text.rb

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,11 @@ module Elements
33
class Text
44
include Element
55
delegate :content, :content=, :to => :@node
6-
TAG = 't'
6+
7+
def self.tag
8+
't'
9+
end
10+
711

812
def initialize(node)
913
@node = node

0 commit comments

Comments
 (0)