-
-
Save anonymous/0ea039f7ff22d0239117 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
module Color | |
def colorize(color, options = {}) | |
background = options[:background] || options[:bg] || false | |
style = options[:style] | |
offsets = ["gray","red", "green", "yellow", "blue", "magenta", "cyan","white"] | |
styles = ["normal","bold","dark","italic","underline","xx","xx","underline","xx","strikethrough"] | |
start = background ? 40 : 30 | |
color_code = start + (offsets.index(color) || 8) | |
style_code = styles.index(style) || 0 | |
"\e[#{style_code};#{color_code}m#{self}\e[0m" | |
end | |
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
FileDirectory.rb:24:in `block in listFile': undefined method `colorize' | |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
require 'fileutils' | |
require_relative 'color' | |
module FileAttr | |
def pathFile | |
@@done = "/mnt/donner/" | |
end | |
def listFile | |
FileUtils.cd(pathFile) | |
dirValue = Dir.glob("#{@@done}/*") | |
puts "Files in #{@@done} \n" | |
dirValue.each do |f| | |
name = File.basename(f) | |
puts name.colorize("blue", :style => "italic") | |
end | |
end | |
class String | |
include Color | |
end | |
end | |
~ |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment