Class: RIO::CmdPipe::RRL
- Defined in:
- lib/rio/scheme/cmdpipe.rb
Constant Summary collapse
Instance Attribute Summary collapse
-
#piper ⇒ Object
readonly
Returns the value of attribute piper.
Class Method Summary collapse
Instance Method Summary collapse
- #append_to_query(rios) ⇒ Object
- #ensure_rio(arg) ⇒ Object
-
#initialize(u, *args) ⇒ RRL
constructor
A new instance of RRL.
- #initialize_copy(other) ⇒ Object
- #open(m, *args) ⇒ Object
- #query ⇒ Object
- #query=(a) ⇒ Object
- #run ⇒ Object
- #to_s ⇒ Object
Constructor Details
#initialize(u, *args) ⇒ RRL
Returns a new instance of RRL.
43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 |
# File 'lib/rio/scheme/cmdpipe.rb', line 43 def initialize(u, *args) nuri = case u when ::Alt::URI::Base,RIO::CmdPipe,RIO::CmdIO u else ::Alt::URI.parse(u) end super(nuri) case uri.scheme when 'cmdio' rios = args.map{ |el| ensure_rio(el) } self.query = [ensure_rio(uri),rios] when 'cmdpipe' rios = args.map{ |el| ensure_rio(el) } self.append_to_query(rios) else rios = args.map{ |el| ensure_rio(el) } self.query = [ensure_rio(uri),rios] end end |
Instance Attribute Details
#piper ⇒ Object (readonly)
Returns the value of attribute piper.
41 42 43 |
# File 'lib/rio/scheme/cmdpipe.rb', line 41 def piper @piper end |
Class Method Details
.parse(*a) ⇒ Object
70 71 72 73 |
# File 'lib/rio/scheme/cmdpipe.rb', line 70 def self.parse(*a) u = a.shift.sub(/^rio:/,'') new(u,*a) end |
Instance Method Details
#append_to_query(rios) ⇒ Object
92 93 94 95 96 97 98 99 100 101 102 103 104 |
# File 'lib/rio/scheme/cmdpipe.rb', line 92 def append_to_query(rios) q = self.query case q when nil self.query = rios when Alt::URI::Base self.query = [rios].flatten when ::Array self.query = q + [rios].flatten else raise ArgumentError, "append_to_query: #{q}, #{uris}" end end |
#ensure_rio(arg) ⇒ Object
63 64 65 66 67 68 69 |
# File 'lib/rio/scheme/cmdpipe.rb', line 63 def ensure_rio(arg) case arg when RIO::Rio then arg when RIO::State::Base then arg.clone_rio else RIO::Rio.new(arg) end end |
#initialize_copy(other) ⇒ Object
105 106 107 |
# File 'lib/rio/scheme/cmdpipe.rb', line 105 def initialize_copy(other) super end |
#open(m, *args) ⇒ Object
120 121 122 |
# File 'lib/rio/scheme/cmdpipe.rb', line 120 def open(m,*args) run end |
#query ⇒ Object
81 82 83 84 85 86 87 88 89 90 |
# File 'lib/rio/scheme/cmdpipe.rb', line 81 def query v = uri.query case v when nil then v when ::Array v.map{ |el| CxURI.new(el).to_rio } else CxURI.new(v).to_rio end end |
#query=(a) ⇒ Object
74 75 76 77 78 79 80 |
# File 'lib/rio/scheme/cmdpipe.rb', line 74 def query=(a) uri.query = if a.instance_of?(::Array) a.map{ |el| CxURI.new(ensure_rio(el)).to_s } else CxURI.new(ensure_rio(a)).to_s end end |
#run ⇒ Object
111 112 113 114 115 116 117 118 119 |
# File 'lib/rio/scheme/cmdpipe.rb', line 111 def run rios = self.query (1...rios.size-1).each { |i| rios[i].w! } (1...rios.size).each { |i| rios[i-1] > rios[i] } rios.each { |r| r.close.softreset } rios[-1] end |
#to_s ⇒ Object
108 109 110 |
# File 'lib/rio/scheme/cmdpipe.rb', line 108 def to_s() super end |