Class: RIO::CmdPipe::RL

Inherits:
RL::IOIBase
  • Object
show all
Defined in:
lib/rio/scheme/cmdpipe.rb

Constant Summary collapse

RIOSCHEME =
'cmdpipe'
RIOPATH =
RIO::RL::CHMAP.invert[RIOSCHEME].to_s.freeze
SPLIT_RE =
%r|(?:([^\|]+)(?:\|([^\|]+))*)?$|.freeze

Instance Attribute Summary collapse

Class Method Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(*args) ⇒ RL

Returns a new instance of RL.



51
52
53
54
55
56
57
58
59
60
61
# File 'lib/rio/scheme/cmdpipe.rb', line 51

def initialize(*args)
  case args[0]
  when CmdPipe::RL
    @piper = args[0].piper
  when Piper::Base 
    @piper = args[0]
  else
    @piper = Piper::Base.new(*args)
  end
  super
end

Instance Attribute Details

#piperObject (readonly)

Returns the value of attribute piper.



49
50
51
# File 'lib/rio/scheme/cmdpipe.rb', line 49

def piper
  @piper
end

Class Method Details

.splitrl(s) ⇒ Object



81
82
83
84
85
86
87
88
89
90
91
92
93
# File 'lib/rio/scheme/cmdpipe.rb', line 81

def self.splitrl(s)
  #p "S='#{s}'"
  sub,opq,whole = split_riorl(s)
  if opq.nil? or opq.empty?
    []
  elsif bm = SPLIT_RE.match(opq)
    escaped_cmd = bm[1]
    cmd = URI.unescape(escaped_cmd)
    [cmd]
  else
    []
  end
end

Instance Method Details

#initialize_copy(*args) ⇒ Object



62
63
64
65
# File 'lib/rio/scheme/cmdpipe.rb', line 62

def initialize_copy(*args)
  super
  @piper = @piper.clone
end

#opaqueObject



66
67
68
69
# File 'lib/rio/scheme/cmdpipe.rb', line 66

def opaque()
  #p callstr('opaque')
  @piper.rios.map{|cmd| URI.escape(cmd.to_s,RIO::RL::ESCAPE)}.join('|')
end

#open(m, *args) ⇒ Object



74
75
76
77
78
79
# File 'lib/rio/scheme/cmdpipe.rb', line 74

def open(m,*args)
  @outp = rio(?")
  rp = Piper::Base.new(@piper,@outp)
  rp.run
  @outp
end

#to_sObject



70
71
72
73
# File 'lib/rio/scheme/cmdpipe.rb', line 70

def to_s()
  return "" if @piper.rios.nil? or @piper.rios.empty?
  @piper.rios.map{|cmd| cmd.to_s}.join('|')
end