Class: ProcessSip::Adapter

Inherits:
Object
  • Object
show all
Defined in:
lib/process_sip.rb

Instance Method Summary collapse

Constructor Details

#initialize(name) ⇒ Adapter

Returns a new instance of Adapter.



27
28
29
# File 'lib/process_sip.rb', line 27

def initialize(name)
  @name, @context, @preprint = name.dasherize, Context.new, false
end

Instance Method Details

#call(name, &block) ⇒ Object



34
35
36
37
38
39
# File 'lib/process_sip.rb', line 34

def call(name, *, **, &block)
  chain = [@name, @context.arguments, name.to_s.dasherize, process(*, **)].flatten.map(&:shellescape).join(" ")
  puts chain if @preprint

  IO.popen(chain, &block || -> { _1.read.chomp })
end

#omit(*keys) ⇒ Object



31
# File 'lib/process_sip.rb', line 31

def omit(*keys)     = clone_with(context: @context.except(*keys))

#preprintObject



51
# File 'lib/process_sip.rb', line 51

def preprint = clone_with(preprint: true)

#silentObject



52
# File 'lib/process_sip.rb', line 52

def silent   = clone_with(preprint: false)

#with(**options) ⇒ Object



32
# File 'lib/process_sip.rb', line 32

def with(**options) = clone_with(context: @context.merge(**options))