Skip to content

Instantly share code, notes, and snippets.

@zyriuse75
Created December 1, 2014 12:48
Show Gist options
  • Save zyriuse75/dc2596501849f3c76e1f to your computer and use it in GitHub Desktop.
Save zyriuse75/dc2596501849f3c76e1f to your computer and use it in GitHub Desktop.
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
$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
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