Class: RIO::CmdPipe::Stream::Reset

Inherits:
State::Base show all
Includes:
Ops::Path::URI
Defined in:
lib/rio/scheme/cmdpipe.rb

Constant Summary

Constants inherited from State::Base

State::Base::KIOSYMS

Instance Attribute Summary

Attributes inherited from State::Base

#data, #try_state

Instance Method Summary collapse

Methods included from Ops::Path::URI

#abs, #absolute?, #base, #merge, #rel, #route_from, #route_to, #setbase

Methods included from Fwd

#fwd, #fwd_reader, #fwd_readers, #fwd_writer, #fwd_writers

Methods inherited from State::Base

#==, #===, #=~, #base_state, #became, #become, #callstr, #clone_rio, default_cx, #ensure_cmd_rio, #ensure_rio, #error, #fs, #gofigure, #hash, #initialize, #initialize_copy, #method_missing, #method_missing_trace_str, new_other, #new_rio, #new_rio_cx, #reset, #retryreset, #softreset, #stream?, #to_a, #to_ary, #to_rl, #to_uri, #to_url, #uri, #when_missing

Methods included from ZipFile::Cx

#zipfile

Methods included from Symantics

#rtn_new, #rtn_reset, #rtn_rio, #rtn_self, #rtn_val

Methods included from Ext::YAML::Cx

#document, #documents, #object, #objects, #skipdocuments, #skipobjects, #yaml, #yaml?, #yamldoc

Methods included from Ext::SplitLines::Cx

#columns, #columns?, #skipcolumns, #splitlines, #splitlines?

Methods included from Ext::CSV::Cx

#columns, #columns?, #csv, #csv?, #fields, #fields?, #headers, #headers?, #skipcolumns, #skipfields

Methods included from RIO::Cx::Methods

#+@, #_arg_skip, #_noarg_skip, #a, #a!, #all, #all?, #binmode, #binmode?, #bytes, #bytes_, #closeoncopy, #closeoncopy?, #closeoneof, #closeoneof?, #copying, #copying?, #copying_done, #copying_from, #copying_from?, #copying_from_done, #copying_to, #copying_to?, #copying_to_done, #dir_iter?, #dirs, #enc, #enc?, #enc_opts?, #entries, #ext, #ext?, #ext_enc?, #files, #gzip, #gzip?, #inputmode?, #int_enc?, #line, #line_, #lines, #lines_, make_filter_methods, #mode, #mode?, #noall, #noautoclose, #nocloseoncopy, #nocloseoneof, #noext, #norecurse, #nostreamenum, #nostreamenum?, #nosync, #outputmode?, #r, #r!, #record, #record_, #records, #records_, #recurse, #row, #row_, #rows, #rows_, #skip, #skipdirs, #skipentries, #skipfiles, #skiplines, #skipping?, #skiprecords, #skiprecords_, #skiprows, #split, #stream_iter?, #sync, #sync?, #w, #w!

Constructor Details

This class inherits a constructor from RIO::State::Base

Dynamic Method Handling

This class handles dynamic methods through the method_missing method in the class RIO::State::Base

Instance Method Details

#check?Boolean

Returns:

  • (Boolean)


127
# File 'lib/rio/scheme/cmdpipe.rb', line 127

def check?() true end

#has_output_dest?(nrio) ⇒ Boolean

Returns:

  • (Boolean)


138
139
140
# File 'lib/rio/scheme/cmdpipe.rb', line 138

def has_output_dest?(nrio)
  !%w[cmdio cmdpipe].include?(last_rio(nrio).scheme)
end

#last_rio(r) ⇒ Object



133
134
135
136
# File 'lib/rio/scheme/cmdpipe.rb', line 133

def last_rio(r)
  r = r.rl.query[-1] while r.scheme == 'cmdpipe'
  r
end

#runObject



141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
# File 'lib/rio/scheme/cmdpipe.rb', line 141

def run
  rios = get_rios(self)

  rio0 = rios.shift
  input = if rio0.scheme == 'cmdio'
            rio0.rl.fib_proc(::RIO::Mode::Str.new("r"))
          else
            Cmd::FromEnum.new(rio0.to_enum)
          end
  procs = []
  while rios.size > 1
    fp = rios.shift.rl.fib_proc(::RIO::Mode::Str.new('w+'))
    procs.unshift(fp) 
  end
  orio = rios.shift
  orio.touch if orio && orio.scheme.nil? # TODO: is this right???
  output = Cmd::ToOutput.new(orio)
  output.resume procs + [input]
  orio
end

#|(arg) ⇒ Object



128
129
130
131
132
# File 'lib/rio/scheme/cmdpipe.rb', line 128

def |(arg)
  ario = ensure_cmd_rio(arg)
  nrio = new_rio(self,ario)
  has_output_dest?(nrio) ? nrio.run :  nrio
end