Skip to content

Commit 78521dd

Browse files
authored
Merge pull request ruby#1341 from Shopify/vs-make-to-rdoc-headings-more-idiomatic
Move default RDoc headings to a constant
2 parents aa9f509 + 2c151c6 commit 78521dd

File tree

1 file changed

+11
-10
lines changed

1 file changed

+11
-10
lines changed

lib/rdoc/markup/to_rdoc.rb

Lines changed: 11 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,16 @@
33
# Outputs RDoc markup as RDoc markup! (mostly)
44

55
class RDoc::Markup::ToRdoc < RDoc::Markup::Formatter
6+
DEFAULT_HEADINGS = {
7+
1 => ['= ', ''],
8+
2 => ['== ', ''],
9+
3 => ['=== ', ''],
10+
4 => ['==== ', ''],
11+
5 => ['===== ', ''],
12+
6 => ['====== ', '']
13+
}
14+
DEFAULT_HEADINGS.default = []
15+
DEFAULT_HEADINGS.freeze
616

717
##
818
# Current indent amount for output in characters
@@ -49,16 +59,7 @@ def initialize markup = nil
4959
@width = 78
5060
init_tags
5161

52-
@headings = {}
53-
@headings.default = []
54-
55-
@headings[1] = ['= ', '']
56-
@headings[2] = ['== ', '']
57-
@headings[3] = ['=== ', '']
58-
@headings[4] = ['==== ', '']
59-
@headings[5] = ['===== ', '']
60-
@headings[6] = ['====== ', '']
61-
62+
@headings = DEFAULT_HEADINGS.dup
6263
@hard_break = "\n"
6364
end
6465

0 commit comments

Comments
 (0)