class Mexico::Util::FancyWriter
Attributes
prefix_stack[R]
stream[R]
Public Class Methods
new(p_stream, &block)
click to toggle source
# File lib/mexico/util/fancy_writer.rb, line 8 def initialize(p_stream, &block) @stream = p_stream @prefix_stack = [] if block_given? instance_eval &block end end
Public Instance Methods
comment(comment_string='
click to toggle source
# File lib/mexico/util/fancy_writer.rb, line 22 def comment(comment_string='# ', &block) if block_given? prepend(comment_string, &block) end end
indent(number=2, &block)
click to toggle source
# File lib/mexico/util/fancy_writer.rb, line 28 def indent(number=2, &block) prepend(' '*number, &block) end
prepend(prepend_string=' ', &block)
click to toggle source
# File lib/mexico/util/fancy_writer.rb, line 16 def prepend(prepend_string=' ', &block) @prefix_stack << prepend_string instance_eval &block @prefix_stack.pop end
tab_indent(number=2, &block)
click to toggle source
# File lib/mexico/util/fancy_writer.rb, line 32 def tab_indent(number=2, &block) prepend("\t"*number, &block) end