mirror of
https://github.com/zhigang1992/synx.git
synced 2026-04-30 05:35:24 +08:00
Merge pull request #36 from alexgenco/refactor_tabber
Remove class variables from Tabber
This commit is contained in:
@@ -1,39 +1,39 @@
|
|||||||
module Synx
|
module Synx
|
||||||
class Tabber
|
class Tabber
|
||||||
|
|
||||||
@@options = {}
|
@options = {}
|
||||||
@@tabbing = 0
|
@tabbing = 0
|
||||||
|
|
||||||
class << self
|
class << self
|
||||||
def increase(n=1)
|
def increase(n=1)
|
||||||
@@tabbing += n
|
@tabbing += n
|
||||||
end
|
end
|
||||||
|
|
||||||
def decrease(n=1)
|
def decrease(n=1)
|
||||||
@@tabbing -= n
|
@tabbing -= n
|
||||||
@@tabbing = 0 if @@tabbing < 0
|
@tabbing = 0 if @tabbing < 0
|
||||||
end
|
end
|
||||||
|
|
||||||
def current
|
def current
|
||||||
@@tabbing
|
@tabbing
|
||||||
end
|
end
|
||||||
|
|
||||||
def reset
|
def reset
|
||||||
@@tabbing = 0
|
@tabbing = 0
|
||||||
self.options = {}
|
self.options = {}
|
||||||
end
|
end
|
||||||
|
|
||||||
def options=(options = {})
|
def options=(options = {})
|
||||||
@@options = options
|
@options = options
|
||||||
end
|
end
|
||||||
|
|
||||||
def options
|
def options
|
||||||
@@options
|
@options
|
||||||
end
|
end
|
||||||
|
|
||||||
def puts(str="")
|
def puts(str="")
|
||||||
str = str.uncolorize if options[:no_color]
|
str = str.uncolorize if options[:no_color]
|
||||||
Kernel.puts (a_single_tab * @@tabbing) + str.to_s unless options[:quiet]
|
Kernel.puts (a_single_tab * @tabbing) + str.to_s unless options[:quiet]
|
||||||
end
|
end
|
||||||
|
|
||||||
def a_single_tab
|
def a_single_tab
|
||||||
|
|||||||
Reference in New Issue
Block a user