Module: Ifilter

Defined in:
lib/ifilter.rb,
lib/ifilter/input.rb,
lib/ifilter/client.rb,
lib/ifilter/window.rb,
lib/ifilter/version.rb

Defined Under Namespace

Classes: Client, Input, Window

Constant Summary collapse

VERSION =
'0.2.2'

Class Method Summary collapse

Class Method Details

.filtering(array) ⇒ Object



6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
# File 'lib/ifilter.rb', line 6

def self.filtering(array)
  name = caller.last.match(/(?<name>[^\/]+?)(\.|:)/)[:name].capitalize

  isatty = STDOUT.isatty

  unless isatty
    stdout_old = STDOUT.dup
    STDOUT.reopen('/dev/tty')
  end

  client = Client.new(name)
  result = client.execute(array)

  unless isatty
    STDOUT.flush
    STDOUT.reopen(stdout_old)
  end

  result
end