Class: Slop::BoolOption

Inherits:
Option
  • Object
show all
Defined in:
lib/ermir/argv_parser.rb

Instance Method Summary collapse

Instance Method Details

#call(*args) ⇒ Object



28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
# File 'lib/ermir/argv_parser.rb', line 28

def call(*args)
  if @flags == %w[-p --pipe]
    if !$stdin.tty?
      obj = $stdin.each_byte.to_a.pack("C*")
      unless Utils.stream_header_valid?(obj)
        Utils.error_and_abort!(Errors::STDIN_CORRUPTED_ERROR, "--pipe")
      end
      obj
    else
      Utils.error_and_abort!(Errors::STDIN_EMPTY_ERROR, "--pipe")
    end
  else
    old_call(*args)
  end
end

#old_callObject



27
# File 'lib/ermir/argv_parser.rb', line 27

alias_method :old_call, :call