Class: TYUtil::TYPuts

Inherits:
Object
  • Object
show all
Defined in:
lib/tycli/util/puts_util.rb

Constant Summary collapse

ERROR_KEYS =
[
	"fatal",
	"error",
	"can not",
	"not found"
]

Class Method Summary collapse

Class Method Details

.filter(target, keys) ⇒ Object



31
32
33
# File 'lib/tycli/util/puts_util.rb', line 31

def self.filter(target, keys)
	filter_color(target, keys, 'yellow', '[!tuya-cli]')
end

.filter_color(target, keys, color, pre) ⇒ Object



12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
# File 'lib/tycli/util/puts_util.rb', line 12

def self.filter_color(target, keys, color, pre)
	target.each_line do |s|

		eval_command = ""
		keys.each do |key|
			temp = ""
			if eval_command.length > 0
				temp = " || "
			end
			eval_command = "#{eval_command}#{temp}s.include?('#{key}')"
		end
		if eval_command.length > 0 && (eval eval_command)
			out = "#{pre} #{s}".gsub!("'","")
			eval "puts '#{out}'.#{color}"
		end
	end

end