Sha256: 59d58820f74a21c02230253296db224f22bcc837907bebe5b0a8bbe9c93e3bbd
Contents?: true
Size: 1.7 KB
Versions: 22
Compression:
Stored size: 1.7 KB
Contents
require_relative './color.rb' class Console def self.debug message if(defined?(DEV_TASKS)) if(DEV_TASKS.has_key?(:debug)) puts message end end end def self.print message puts message end def self.announce_task_start task line = Color.bold + Color.cyan + "[:" + task + "]" + Color.clear #while(line.length < 80) do # line = line + "=" #end #puts " " puts line + Color.clear end def self.announce_task_end task, elapsed_str line = task + " completed in " + Color.green + elapsed_str + Color.clear puts line + Color.clear puts " " end def self.print_hash(indent,hash) max_length=0 hash.each { |name,value| max_length=name.to_s.length if name.to_s.length > max_length } max_length=max_length+1 index=0 hash.each do |name,value| prefix = "#{indent}#{name.to_s}".rjust(max_length) if value.kind_of?(Hash) print_hash(prefix+" ",value) elsif value.kind_of?(Array) Console.print_array prefix,name,value else puts Color.bold + prefix + " " + Color.clear + Color.green + value.to_s + Color.clear end index+=1 indent=" ".rjust(indent.length) end end def self.print_array(prefix,key,array) array.each do |v| if v.kind_of?(Hash) puts Color.bold + prefix + Color.clear print_hash( prefix + " ".rjust(max_length),v) else puts Color.bold + prefix + " " + Color.clear + Color.green + v.to_s + Color.clear if v.kind_of?(String) #prefix = indent + " ".rjust(max_length-1) #prefix = " ".rjust(indent.length+max_length-1) words = prefix.split(' ') prefix = " ".rjust(prefix.length) end end end end
Version data entries
22 entries across 22 versions & 1 rubygems