Method: TYUtil::TYPuts.filter_content

Defined in:
lib/tycli/util/puts_util.rb

.filter_content(target, keys, pre) ⇒ Object



54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
# File 'lib/tycli/util/puts_util.rb', line 54

def self.filter_content(target, keys, pre)

  regular_temp = ""
  is_put_pre = false
  keys.each do |key|
    temp = ""
    if regular_temp.length > 0
      temp = "|"
    end
    regular_temp = "#{regular_temp}#{temp}(.*)#{key}(.*)"
  end

  regular = "^(#{regular_temp})$"
  target.gsub(/#{regular}/) do |matched|

    if !is_put_pre
      is_put_pre = true
      puts pre.yellow
      puts "\n"
    end

    if matched.length < 2000
      puts matched.magenta
      puts "\n"
    end
  end
end