-
-
Save zyriuse75/dc2596501849f3c76e1f 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
$LOAD_PATH << './lib' | |
require 'color' | |
class Download | |
require color | |
def wget(arr) | |
FileUtils.cd('/mnt/list') | |
site = "xxxxx" | |
arr.each do |f| | |
wget = system("wget #{site}#{f}") | |
logger.info("wget: #{f}".colorize("blue")) | |
end | |
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
Down.rb:114:in `block (2 levels) in wget': undefined method `colorize' for #<String:0x00000001152d30> (NoMethodError) | |
from /usr/local/rvm/gems/ruby-1.9.3-p547/gems/nokogiri-1.6.2.1/lib/nokogiri/xml/node_set.rb:237:in `block in each' | |
from /usr/local/rvm/gems/ruby-1.9.3-p547/gems/nokogiri-1.6.2.1/lib/nokogiri/xml/node_set.rb:236:in `upto' | |
from /usr/local/rvm/gems/ruby-1.9.3-p547/gems/nokogiri-1.6.2.1/lib/nokogiri/xml/node_set.rb:236:in `each' |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment