lib/ratch/io.rb in ratch-1.0.0 vs lib/ratch/io.rb in ratch-1.1.0

- old
+ new

@@ -1,6 +1,7 @@ -require 'facets/consoleutils' +require 'clio/consoleutils' +require 'clio/ansicode' module Ratch # = Ratch IO # @@ -8,30 +9,29 @@ # basic input/output "dialog" between user and script. # class IO # - attr :runmode + attr :commandline # - def initialize(runmode) - @runmode = runmode + def initialize(commandline) + @commandline = commandline end - def force? ; runmode.force? ; end - def quiet? ; runmode.quiet? ; end - def trace? ; runmode.trace? ; end - def debug? ; runmode.debug? ; end - def dryrun? ; runmode.dryrun? ; end - def noharm? ; runmode.noharm? ; end + def force? ; commandline.force? ; end + def quiet? ; commandline.quiet? ; end + def trace? ; commandline.trace? ; end + def debug? ; commandline.debug? ; end + def pretend? ; commandline.pretend? ; end # Internal status report. # # Only output if dryrun or trace mode. # def status(message) - if runmode.dryrun? or runmode.trace? + if pretend? or trace? puts message end end # Convenient method to get simple console reply. @@ -70,11 +70,11 @@ end # # def printline(left, right='', options={}) - return if runmode.quiet? + return if quiet? separator = options[:seperator] || options[:sep] || ' ' padding = options[:padding] || options[:pad] || 0 left, right = left.to_s, right.to_s @@ -99,16 +99,16 @@ def colorize(text) return text unless text.color if PLATFORM =~ /win/ text.to_s else - ANSICode.send(text.color){ text.to_s } + Clio::ANSICode.send(text.color){ text.to_s } end end # def screen_width - ConsoleUtils.screen_width + Clio::ConsoleUtils.screen_width end end end