PrettyComment 0.1.1 → 0.1.2
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- data/lib/PrettyComment.rb +36 -4
- metadata +1 -1
data/lib/PrettyComment.rb
CHANGED
@@ -16,8 +16,8 @@ end
|
|
16
16
|
|
17
17
|
#----------------------------------------------------------------------------------------------------------------------#
|
18
18
|
|
19
|
-
def self.separator(char='=')
|
20
|
-
|
19
|
+
def self.separator(char='=', left='#', right='#')
|
20
|
+
left + (char * (terminal_width - left.length - right.length)) + right
|
21
21
|
end
|
22
22
|
|
23
23
|
|
@@ -73,6 +73,7 @@ def self.format_line(text, prefix, only_first_line_prefix=false, suffix='', alte
|
|
73
73
|
result.join("\n")
|
74
74
|
end
|
75
75
|
|
76
|
+
|
76
77
|
#----------------------------------------------------------------------------------------------------------------------#
|
77
78
|
|
78
79
|
def self.heading(a_text, a_delimiter = '=')
|
@@ -124,14 +125,45 @@ class Box
|
|
124
125
|
#----------------------------------------------------------------------------------------------------------------------#
|
125
126
|
|
126
127
|
def hline(a_char = @top)
|
127
|
-
@linebuffer << PrettyComment.separator(a_char)
|
128
|
+
@linebuffer << PrettyComment.separator(a_char, left, right)
|
129
|
+
end
|
130
|
+
|
131
|
+
|
132
|
+
#----------------------------------------------------------------------------------------------------------------------#
|
133
|
+
|
134
|
+
def heading(a_string, a_char)
|
135
|
+
@linebuffer << PrettyComment.separator(a_char, left, right)
|
136
|
+
@linebuffer << PrettyComment::format_line(a_string, left, false, right)
|
137
|
+
@linebuffer << PrettyComment.separator(a_char, left, right)
|
138
|
+
end
|
139
|
+
|
140
|
+
|
141
|
+
#----------------------------------------------------------------------------------------------------------------------#
|
142
|
+
|
143
|
+
def h1(a_string)
|
144
|
+
heading(a_string, "#")
|
145
|
+
end
|
146
|
+
|
147
|
+
|
148
|
+
#----------------------------------------------------------------------------------------------------------------------#
|
149
|
+
|
150
|
+
def h2(a_string)
|
151
|
+
heading(a_string, "=")
|
152
|
+
end
|
153
|
+
|
154
|
+
|
155
|
+
#----------------------------------------------------------------------------------------------------------------------#
|
156
|
+
|
157
|
+
def h3(a_string)
|
158
|
+
heading(a_string, "-")
|
128
159
|
end
|
129
160
|
|
130
161
|
|
131
162
|
#----------------------------------------------------------------------------------------------------------------------#
|
132
163
|
|
133
164
|
def to_s
|
134
|
-
|
165
|
+
newline = "\n"
|
166
|
+
PrettyComment::separator(top) + newline + @linebuffer.join("\n") + newline + PrettyComment::separator(bottom)
|
135
167
|
end
|
136
168
|
|
137
169
|
#----------------------------------------------------------------------------------------------------------------------#
|