Class: PrettyComment::Box
- Inherits:
-
Object
- Object
- PrettyComment::Box
- Defined in:
- lib/PrettyComment.rb
Overview
———————————————————————————————————————-#
Constant Summary collapse
- @@left =
@@right = '#'
- @@top =
@@bottom = '='
- @@width =
PrettyComment::width
Class Attribute Summary collapse
-
.bottom ⇒ Object
Returns the value of attribute bottom.
-
.right ⇒ Object
Returns the value of attribute right.
-
.top ⇒ Object
Returns the value of attribute top.
-
.width ⇒ Object
Returns the value of attribute width.
Instance Attribute Summary collapse
-
#bottom ⇒ Object
Returns the value of attribute bottom.
-
#left ⇒ Object
Returns the value of attribute left.
-
#right ⇒ Object
Returns the value of attribute right.
-
#top ⇒ Object
Returns the value of attribute top.
-
#width ⇒ Object
Returns the value of attribute width.
Class Method Summary collapse
-
.left=(a_left) ⇒ Object
———————————————————————————————————————-#.
-
.style=(a_style) ⇒ Object
———————————————————————————————————————-#.
Instance Method Summary collapse
-
#box_bottom(a_bottom) ⇒ Object
———————————————————————————————————————-#.
-
#box_left(a_left) ⇒ Object
———————————————————————————————————————-#.
-
#box_right(a_right) ⇒ Object
———————————————————————————————————————-#.
-
#box_style(a_style) ⇒ Object
———————————————————————————————————————-#.
-
#box_top(a_top) ⇒ Object
———————————————————————————————————————-#.
-
#box_width(a_width) ⇒ Object
———————————————————————————————————————-#.
-
#cloaker(&b) ⇒ Object
———————————————————————————————————————-#.
-
#h1(a_string) ⇒ Object
———————————————————————————————————————-#.
-
#h2(a_string) ⇒ Object
———————————————————————————————————————-#.
-
#h3(a_string) ⇒ Object
———————————————————————————————————————-#.
-
#heading(a_string, a_char) ⇒ Object
———————————————————————————————————————-#.
-
#hline(a_char = @top) ⇒ Object
———————————————————————————————————————-#.
-
#initialize(*a, &b) ⇒ Box
constructor
A new instance of Box.
-
#inspect ⇒ Object
———————————————————————————————————————-#.
-
#para(a_string) ⇒ Object
———————————————————————————————————————-#.
-
#to_s ⇒ Object
———————————————————————————————————————-#.
Constructor Details
#initialize(*a, &b) ⇒ Box
Returns a new instance of Box.
142 143 144 145 146 147 148 149 150 |
# File 'lib/PrettyComment.rb', line 142 def initialize *a, &b @left = @@left @right = @@right @top = @@top @bottom = @@bottom @width = @@width @linebuffer = [] cloaker(&b).bind(self).call(*a) if b end |
Class Attribute Details
.bottom ⇒ Object
Returns the value of attribute bottom.
135 136 137 |
# File 'lib/PrettyComment.rb', line 135 def bottom @bottom end |
.right ⇒ Object
Returns the value of attribute right.
135 136 137 |
# File 'lib/PrettyComment.rb', line 135 def right @right end |
.top ⇒ Object
Returns the value of attribute top.
135 136 137 |
# File 'lib/PrettyComment.rb', line 135 def top @top end |
.width ⇒ Object
Returns the value of attribute width.
135 136 137 |
# File 'lib/PrettyComment.rb', line 135 def width @width end |
Instance Attribute Details
#bottom ⇒ Object
Returns the value of attribute bottom.
141 142 143 |
# File 'lib/PrettyComment.rb', line 141 def bottom @bottom end |
#left ⇒ Object
Returns the value of attribute left.
141 142 143 |
# File 'lib/PrettyComment.rb', line 141 def left @left end |
#right ⇒ Object
Returns the value of attribute right.
141 142 143 |
# File 'lib/PrettyComment.rb', line 141 def right @right end |
#top ⇒ Object
Returns the value of attribute top.
141 142 143 |
# File 'lib/PrettyComment.rb', line 141 def top @top end |
#width ⇒ Object
Returns the value of attribute width.
141 142 143 |
# File 'lib/PrettyComment.rb', line 141 def width @width end |
Class Method Details
.left=(a_left) ⇒ Object
———————————————————————————————————————-#
155 156 157 |
# File 'lib/PrettyComment.rb', line 155 def self.left=(a_left) @@left = a_left end |
.style=(a_style) ⇒ Object
———————————————————————————————————————-#
190 191 192 193 194 195 |
# File 'lib/PrettyComment.rb', line 190 def self.style=(a_style) style = PrettyComment::styles[a_style] @@left = style[:left] @@right = style[:right] end |
Instance Method Details
#box_bottom(a_bottom) ⇒ Object
———————————————————————————————————————-#
231 232 233 |
# File 'lib/PrettyComment.rb', line 231 def box_bottom(a_bottom) @bottom = a_bottom end |
#box_left(a_left) ⇒ Object
———————————————————————————————————————-#
210 211 212 |
# File 'lib/PrettyComment.rb', line 210 def box_left(a_left) @left = a_left end |
#box_right(a_right) ⇒ Object
———————————————————————————————————————-#
217 218 219 |
# File 'lib/PrettyComment.rb', line 217 def box_right(a_right) @right = a_right end |
#box_style(a_style) ⇒ Object
———————————————————————————————————————-#
200 201 202 203 204 205 |
# File 'lib/PrettyComment.rb', line 200 def box_style(a_style) style = PrettyComment.styles[a_style] @left = style[:left] @right = style[:right] end |
#box_top(a_top) ⇒ Object
———————————————————————————————————————-#
224 225 226 |
# File 'lib/PrettyComment.rb', line 224 def box_top(a_top) @top = a_top end |
#box_width(a_width) ⇒ Object
———————————————————————————————————————-#
238 239 240 |
# File 'lib/PrettyComment.rb', line 238 def box_width(a_width) @width = a_width end |
#cloaker(&b) ⇒ Object
———————————————————————————————————————-#
306 307 308 309 310 311 312 313 |
# File 'lib/PrettyComment.rb', line 306 def cloaker &b (class << self; self; end).class_eval do define_method :cloaker_, &b meth = instance_method :cloaker_ remove_method :cloaker_ meth end end |
#h1(a_string) ⇒ Object
———————————————————————————————————————-#
268 269 270 |
# File 'lib/PrettyComment.rb', line 268 def h1(a_string) heading(a_string, "#") end |
#h2(a_string) ⇒ Object
———————————————————————————————————————-#
275 276 277 |
# File 'lib/PrettyComment.rb', line 275 def h2(a_string) heading(a_string, "=") end |
#h3(a_string) ⇒ Object
———————————————————————————————————————-#
282 283 284 |
# File 'lib/PrettyComment.rb', line 282 def h3(a_string) heading(a_string, "-") end |
#heading(a_string, a_char) ⇒ Object
———————————————————————————————————————-#
259 260 261 262 263 |
# File 'lib/PrettyComment.rb', line 259 def heading(a_string, a_char) @linebuffer << PrettyComment.separator(a_char, left, right) @linebuffer << PrettyComment::format_line(a_string, left, false, right, '', width) @linebuffer << PrettyComment.separator(a_char, left, right) end |
#hline(a_char = @top) ⇒ Object
———————————————————————————————————————-#
252 253 254 |
# File 'lib/PrettyComment.rb', line 252 def hline(a_char = @top) @linebuffer << PrettyComment.separator(a_char, left, right) end |
#inspect ⇒ Object
———————————————————————————————————————-#
299 300 301 |
# File 'lib/PrettyComment.rb', line 299 def inspect to_s end |
#para(a_string) ⇒ Object
———————————————————————————————————————-#
245 246 247 |
# File 'lib/PrettyComment.rb', line 245 def para(a_string) @linebuffer << PrettyComment::format_line(a_string, left, false, right, '', width) end |
#to_s ⇒ Object
———————————————————————————————————————-#
289 290 291 292 293 294 |
# File 'lib/PrettyComment.rb', line 289 def to_s newline = "\n" result = PrettyComment::separator(top, left, right, width) << newline result << @linebuffer.join("\n") << newline result << PrettyComment::separator(bottom, left, right, width) end |