Module: Ifilter

Defined in:
lib/ifilter.rb,
lib/ifilter/input.rb,
lib/ifilter/version.rb,
lib/ifilter/interface.rb

Defined Under Namespace

Classes: Input, Interface

Constant Summary collapse

VERSION =
'0.0.4'

Class Method Summary collapse

Class Method Details

.filtering(array) ⇒ Object



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

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

  isatty = STDOUT.isatty

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

  ifilter = Interface.new(name, array)
  result = ifilter.grep

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

  result
end