lib/synx/tabber.rb in synx-0.0.52 vs lib/synx/tabber.rb in synx-0.0.53
- old
+ new
@@ -1,45 +1,51 @@
module Synx
class Tabber
- @@quiet = false
- @@tabbing = 0
+ @options = {}
+ @tabbing = 0
class << self
def increase(n=1)
- @@tabbing += n
+ @tabbing += n
end
def decrease(n=1)
- @@tabbing -= n
- @@tabbing = 0 if @@tabbing < 0
+ @tabbing -= n
+ @tabbing = 0 if @tabbing < 0
end
def current
- @@tabbing
+ @tabbing
end
def reset
- @@tabbing = 0
- self.quiet = false
+ @tabbing = 0
+ self.options = {}
end
- def quiet=(quiet)
- @@quiet = quiet
+ def options=(options = {})
+ @options = options
end
- def quiet?
- @@quiet
+ def options
+ @options
end
def puts(str="")
- Kernel.puts (a_single_tab * @@tabbing) + str.to_s unless quiet?
+ str = str.uncolorize if options[:no_color]
+ output.puts (a_single_tab * @tabbing) + str.to_s unless options[:quiet]
end
def a_single_tab
return " "
end
private :a_single_tab
+
+ def output
+ options.fetch(:output, $stdout)
+ end
+ private :output
end
end
end