Module: RIO::Cx::Methods
- Included in:
- State::Base
- Defined in:
- lib/rio/filter.rb,
lib/rio/context/cxx.rb,
lib/rio/context/dir.rb,
lib/rio/context/gzip.rb,
lib/rio/context/skip.rb,
lib/rio/context/stream.rb,
lib/rio/context/binmode.rb,
lib/rio/context/copying.rb,
lib/rio/context/methods.rb,
lib/rio/context/methods.rb,
lib/rio/context/methods.rb,
lib/rio/context/methods.rb,
lib/rio/context/methods.rb,
lib/rio/context/methods.rb,
lib/rio/context/methods.rb,
lib/rio/context/encoding.rb,
lib/rio/context/autoclose.rb,
lib/rio/context/autoclose.rb,
lib/rio/context/autoclose.rb
Class Method Summary collapse
Instance Method Summary collapse
- #+@ ⇒ Object
- #_arg_skip(args) ⇒ Object
- #_noarg_skip ⇒ Object
- #a ⇒ Object
- #a! ⇒ Object
- #all(arg = true, &block) ⇒ Object
- #all? ⇒ Boolean
- #binmode(&block) ⇒ Object
- #binmode? ⇒ Boolean
- #bytes(nb = 1, *args, &block) ⇒ Object
- #bytes_(nb = 1, *args, &block) ⇒ Object
- #closeoncopy(arg = true, &block) ⇒ Object
- #closeoncopy? ⇒ Boolean
- #closeoneof(arg = true, &block) ⇒ Object
- #closeoneof? ⇒ Boolean
- #copying(dest) ⇒ Object
- #copying? ⇒ Boolean
- #copying_done(dest) ⇒ Object
- #copying_from ⇒ Object
- #copying_from? ⇒ Boolean
- #copying_from_done ⇒ Object
- #copying_to ⇒ Object
- #copying_to? ⇒ Boolean
- #copying_to_done ⇒ Object
- #dir_iter? ⇒ Boolean
- #dirs(*args, &block) ⇒ Object
- #enc(*args, &block) ⇒ Object
- #enc? ⇒ Boolean
- #enc_opts? ⇒ Boolean
- #entries(*args, &block) ⇒ Object
- #ext(arg = nil) ⇒ Object
- #ext? ⇒ Boolean
- #ext_enc? ⇒ Boolean
- #files(*args, &block) ⇒ Object
- #gzip(arg = true, &block) ⇒ Object
- #gzip? ⇒ Boolean
- #inputmode? ⇒ Boolean
- #int_enc? ⇒ Boolean
- #line(*args, &block) ⇒ Object
- #line_(*args, &block) ⇒ Object
- #lines(*args, &block) ⇒ Object
- #lines_(*args, &block) ⇒ Object
- #mode(arg) ⇒ Object
- #mode? ⇒ Boolean
- #noall(arg = false, &block) ⇒ Object
- #noautoclose(arg = false, &block) ⇒ Object
- #nocloseoncopy(arg = false, &block) ⇒ Object
- #nocloseoneof(arg = false, &block) ⇒ Object
- #noext ⇒ Object
- #norecurse(*args, &block) ⇒ Object
- #nostreamenum(arg = true, &block) ⇒ Object
- #nostreamenum? ⇒ Boolean
- #nosync(arg = false, &block) ⇒ Object
- #outputmode? ⇒ Boolean
- #r ⇒ Object
- #r! ⇒ Object
- #record(*args, &block) ⇒ Object
- #record_(*args, &block) ⇒ Object
- #records(*args, &block) ⇒ Object
- #records_(*args, &block) ⇒ Object
- #recurse(*args, &block) ⇒ Object
- #row(*args, &block) ⇒ Object
- #row_(*args, &block) ⇒ Object
- #rows(*args, &block) ⇒ Object
- #rows_(*args, &block) ⇒ Object
- #skip(*args, &block) ⇒ Object
- #skipdirs(*args, &block) ⇒ Object
- #skipentries(*args, &block) ⇒ Object
- #skipfiles(*args, &block) ⇒ Object
- #skiplines(*args, &block) ⇒ Object
- #skipping? ⇒ Boolean
- #skiprecords(*args, &block) ⇒ Object
- #skiprecords_(*args, &block) ⇒ Object
- #skiprows(*args, &block) ⇒ Object
- #split(*args, &block) ⇒ Object
- #stream_iter? ⇒ Boolean
- #sync(arg = true, &block) ⇒ Object
- #sync? ⇒ Boolean
- #w ⇒ Object
- #w! ⇒ Object
Class Method Details
.make_filter_methods(sym) ⇒ Object
47 48 49 50 51 52 53 54 55 56 57 58 |
# File 'lib/rio/filter.rb', line 47 def self.make_filter_methods(sym) module_eval %{ def #{sym}(arg=true,&block) cx['#{sym}'] = arg add_filter(Filter::#{sym.to_s.capitalize}) if arg and self.ioh each(&block) if block_given? self end def #{sym}?() cxx?('#{sym}') end def no#{sym}(arg=false,&block) #{sym}(arg,&block) end } end |
Instance Method Details
#+@ ⇒ Object
165 |
# File 'lib/rio/context/methods.rb', line 165 def +@() a() end |
#_arg_skip(args) ⇒ Object
31 32 33 34 35 36 |
# File 'lib/rio/context/skip.rb', line 31 def _arg_skip(args) #p callstr('_arg_skip',args,cx.inspect) cx['ss_skipped'] = cx['ss_type'].sub(/^skip/,'') if cx['ss_type'] cx['ss_type'] = 'skip' cx['skip_args'] = args end |
#_noarg_skip ⇒ Object
37 38 39 40 41 |
# File 'lib/rio/context/skip.rb', line 37 def _noarg_skip cx['ss_skipped'] = cx['ss_type'].sub(/^skip/,'') if cx['ss_type'] cx['ss_type'] = 'skip' cx['skipping'] = true end |
#a ⇒ Object
157 |
# File 'lib/rio/context/methods.rb', line 157 def a() cx['outputmode'] = Mode::Str.new('a'); self end |
#a! ⇒ Object
158 |
# File 'lib/rio/context/methods.rb', line 158 def a!() cx['outputmode'] = Mode::Str.new('a+'); self end |
#all(arg = true, &block) ⇒ Object
108 |
# File 'lib/rio/context/methods.rb', line 108 def all(arg=true,&block) cxx('all',arg,&block) end |
#all? ⇒ Boolean
110 |
# File 'lib/rio/context/methods.rb', line 110 def all?() cxx?('all') end |
#binmode(&block) ⇒ Object
38 39 40 41 |
# File 'lib/rio/context/binmode.rb', line 38 def binmode(&block) ioh.binmode unless ioh.nil? cxx('binmode',&block) end |
#binmode? ⇒ Boolean
42 43 44 45 46 47 48 49 |
# File 'lib/rio/context/binmode.rb', line 42 def binmode?() setting = cxx?('binmode') if ioh actual = ioh.binmode? cxx_('binmode',actual) unless actual == setting end cxx?('binmode') end |
#bytes(nb = 1, *args, &block) ⇒ Object
194 195 196 197 198 199 200 201 |
# File 'lib/rio/context/stream.rb', line 194 def bytes(nb=1,*args,&block) _set_sstype('bytes') _set_bytes(nb) _set_itertype('records') _set_rectype('bytes') each(&block) if block_given? self end |
#bytes_(nb = 1, *args, &block) ⇒ Object
202 203 204 205 206 207 208 |
# File 'lib/rio/context/stream.rb', line 202 def bytes_(nb=1,*args,&block) _set_bytes_(nb) _set_itertype('records',false) _set_rectype('bytes',false) each(&block) if block_given? self end |
#closeoncopy(arg = true, &block) ⇒ Object
41 |
# File 'lib/rio/context/autoclose.rb', line 41 def closeoncopy(arg=true,&block) cxx('closeoncopy',arg,&block) end |
#closeoncopy? ⇒ Boolean
43 |
# File 'lib/rio/context/autoclose.rb', line 43 def closeoncopy?() cxx?('closeoncopy') end |
#closeoneof(arg = true, &block) ⇒ Object
31 |
# File 'lib/rio/context/autoclose.rb', line 31 def closeoneof(arg=true,&block) cxx('closeoneof',arg,&block) end |
#closeoneof? ⇒ Boolean
33 |
# File 'lib/rio/context/autoclose.rb', line 33 def closeoneof?() cxx?('closeoneof') end |
#copying(dest) ⇒ Object
38 |
# File 'lib/rio/context/copying.rb', line 38 def (dest) dest.; end |
#copying? ⇒ Boolean
39 |
# File 'lib/rio/context/copying.rb', line 39 def () or end |
#copying_done(dest) ⇒ Object
40 |
# File 'lib/rio/context/copying.rb', line 40 def (dest) dest.; end |
#copying_from ⇒ Object
34 |
# File 'lib/rio/context/copying.rb', line 34 def () cx['copying_from'] = true; self end |
#copying_from? ⇒ Boolean
35 |
# File 'lib/rio/context/copying.rb', line 35 def () cx['copying_from'] end |
#copying_from_done ⇒ Object
36 |
# File 'lib/rio/context/copying.rb', line 36 def () cx.delete('copying_from'); self end |
#copying_to ⇒ Object
30 |
# File 'lib/rio/context/copying.rb', line 30 def () cx['copying_to'] = true; self end |
#copying_to? ⇒ Boolean
31 |
# File 'lib/rio/context/copying.rb', line 31 def () cx['copying_to'] end |
#copying_to_done ⇒ Object
32 |
# File 'lib/rio/context/copying.rb', line 32 def () cx.delete('copying_to'); self end |
#dir_iter? ⇒ Boolean
33 |
# File 'lib/rio/context/dir.rb', line 33 def dir_iter?() cx.has_key?('entry_sel') end |
#dirs(*args, &block) ⇒ Object
71 72 73 |
# File 'lib/rio/context/dir.rb', line 71 def dirs(*args,&block) _set_select(_selkey('dirs'),*args,&block) end |
#enc(*args, &block) ⇒ Object
32 33 34 35 |
# File 'lib/rio/context/encoding.rb', line 32 def enc(*args,&block) _set_enc_from_args(*args) cxx(:enc_args,args,&block) end |
#enc? ⇒ Boolean
45 46 47 48 49 50 51 52 |
# File 'lib/rio/context/encoding.rb', line 45 def enc?() setting = cxx?(:enc_args) #unless ioh.nil? # actual = [ioh. # cxx_(actual) unless actual == setting #end setting end |
#enc_opts? ⇒ Boolean
42 43 44 |
# File 'lib/rio/context/encoding.rb', line 42 def enc_opts?() cx[:enc_opts] end |
#entries(*args, &block) ⇒ Object
65 66 67 |
# File 'lib/rio/context/dir.rb', line 65 def entries(*args,&block) _set_select(_selkey('entries'),*args,&block) end |
#ext(arg = nil) ⇒ Object
132 133 134 135 136 |
# File 'lib/rio/context/methods.rb', line 132 def ext(arg=nil) arg ||= self.extname || "" self.cx['ext'] = arg self end |
#ext? ⇒ Boolean
141 142 143 144 |
# File 'lib/rio/context/methods.rb', line 141 def ext?() self.cx.set_('ext',self.extname || "") if self.cx['ext'].nil? self.cx['ext'] end |
#ext_enc? ⇒ Boolean
39 40 41 |
# File 'lib/rio/context/encoding.rb', line 39 def ext_enc?() ioh ? ioh.external_encoding : cx[:enc_ext] end |
#files(*args, &block) ⇒ Object
68 69 70 |
# File 'lib/rio/context/dir.rb', line 68 def files(*args,&block) _set_select(_selkey('files'),*args,&block) end |
#gzip(arg = true, &block) ⇒ Object
31 32 33 34 35 |
# File 'lib/rio/context/gzip.rb', line 31 def gzip(arg=true,&block) self.cx['gzip'] = arg; each(&block) if block_given? self end |
#gzip? ⇒ Boolean
36 |
# File 'lib/rio/context/gzip.rb', line 36 def gzip?() cxx?('gzip') end |
#inputmode? ⇒ Boolean
164 |
# File 'lib/rio/context/methods.rb', line 164 def inputmode?() cxx?('inputmode') end |
#int_enc? ⇒ Boolean
36 37 38 |
# File 'lib/rio/context/encoding.rb', line 36 def int_enc?() ioh ? ioh.internal_encoding : cx[:enc_int] end |
#line(*args, &block) ⇒ Object
111 112 113 114 115 |
# File 'lib/rio/context/stream.rb', line 111 def line(*args,&block) #p callstr('line',*args) cx['line'] = true self.lines(*args,&block) end |
#line_(*args, &block) ⇒ Object
116 117 118 119 120 |
# File 'lib/rio/context/stream.rb', line 116 def line_(*args,&block) #p callstr('line_',*args) cx.set_('line',true) self.lines_(*args,&block) end |
#lines(*args, &block) ⇒ Object
95 96 97 98 99 100 101 102 103 104 |
# File 'lib/rio/context/stream.rb', line 95 def lines(*args,&block) #p callstr('lines',*args) if skipping? cx['skipping'] = false skiplines(*args,&block) else _set_sstype('lines') _lines(args,_sel,&block) end end |
#lines_(*args, &block) ⇒ Object
105 106 107 108 109 |
# File 'lib/rio/context/stream.rb', line 105 def lines_(*args,&block) #p callstr('lines_',*args) _set_sstype('lines',false) _lines(args,_sel,false,&block) end |
#mode(arg) ⇒ Object
47 48 49 50 51 |
# File 'lib/rio/context/methods.rb', line 47 def mode(arg) # p callstr('mode',arg) self.cx['mode'] = Mode::Str.new(arg) self end |
#mode? ⇒ Boolean
52 53 54 |
# File 'lib/rio/context/methods.rb', line 52 def mode?() self.cx['mode'] end |
#noall(arg = false, &block) ⇒ Object
109 |
# File 'lib/rio/context/methods.rb', line 109 def noall(arg=false,&block) nocxx('all',arg,&block) end |
#noautoclose(arg = false, &block) ⇒ Object
51 52 53 |
# File 'lib/rio/context/autoclose.rb', line 51 def noautoclose(arg=false,&block) closeoncopy(arg).closeoneof(arg,&block) end |
#nocloseoncopy(arg = false, &block) ⇒ Object
42 |
# File 'lib/rio/context/autoclose.rb', line 42 def nocloseoncopy(arg=false,&block) nocxx('closeoncopy',arg,&block) end |
#nocloseoneof(arg = false, &block) ⇒ Object
32 |
# File 'lib/rio/context/autoclose.rb', line 32 def nocloseoneof(arg=false,&block) nocxx('closeoneof',arg,&block) end |
#noext ⇒ Object
137 138 139 140 |
# File 'lib/rio/context/methods.rb', line 137 def noext() ext('') self end |
#norecurse(*args, &block) ⇒ Object
101 102 103 104 105 |
# File 'lib/rio/context/dir.rb', line 101 def norecurse(*args,&block) _addselkey('r_nosel',:dir?,*args).all_ return each(&block) if block_given? self end |
#nostreamenum(arg = true, &block) ⇒ Object
121 |
# File 'lib/rio/context/methods.rb', line 121 def (arg=true,&block) cxx('nostreamenum',arg,&block) end |
#nostreamenum? ⇒ Boolean
122 |
# File 'lib/rio/context/methods.rb', line 122 def () cxx?('nostreamenum') end |
#nosync(arg = false, &block) ⇒ Object
84 85 86 87 |
# File 'lib/rio/context/methods.rb', line 84 def nosync(arg=false,&block) ioh.sync = arg unless ioh.nil? nocxx('sync',arg,&block) end |
#outputmode? ⇒ Boolean
163 |
# File 'lib/rio/context/methods.rb', line 163 def outputmode?() cxx?('outputmode') end |
#r ⇒ Object
161 |
# File 'lib/rio/context/methods.rb', line 161 def r() cx['inputmode'] = Mode::Str.new('r'); self end |
#r! ⇒ Object
162 |
# File 'lib/rio/context/methods.rb', line 162 def r!() cx['inputmode'] = Mode::Str.new('r+'); self end |
#record(*args, &block) ⇒ Object
136 137 138 139 140 |
# File 'lib/rio/context/stream.rb', line 136 def record(*args,&block) #p callstr('record',*args) cx['record'] = true self.records(*args,&block) end |
#record_(*args, &block) ⇒ Object
141 142 143 144 145 |
# File 'lib/rio/context/stream.rb', line 141 def record_(*args,&block) #p callstr('record_',*args) cx.set_('record',true) self.records_(*args,&block) end |
#records(*args, &block) ⇒ Object
122 123 124 125 126 127 128 129 130 |
# File 'lib/rio/context/stream.rb', line 122 def records(*args,&block) if skipping? cx['skipping'] = false skiprecords(*args,&block) else _set_sstype('records') _records(args,_sel,&block) end end |
#records_(*args, &block) ⇒ Object
131 132 133 134 |
# File 'lib/rio/context/stream.rb', line 131 def records_(*args,&block) _set_sstype('records',false) _records(args,_sel,false,&block) end |
#recurse(*args, &block) ⇒ Object
96 97 98 99 100 |
# File 'lib/rio/context/dir.rb', line 96 def recurse(*args,&block) _addselkey('r_sel',:dir?,*args).all_ return each(&block) if block_given? self end |
#row(*args, &block) ⇒ Object
161 162 163 164 165 |
# File 'lib/rio/context/stream.rb', line 161 def row(*args,&block) #p callstr('row',*args) cx['row'] = true self.rows(*args,&block) end |
#row_(*args, &block) ⇒ Object
166 167 168 169 170 |
# File 'lib/rio/context/stream.rb', line 166 def row_(*args,&block) #p callstr('row_',*args) cx.set_('row',true) self.rows_(*args,&block) end |
#rows(*args, &block) ⇒ Object
147 148 149 150 151 152 153 154 155 |
# File 'lib/rio/context/stream.rb', line 147 def rows(*args,&block) if skipping? cx['skipping'] = false skiprows(*args,&block) else _set_sstype('rows') _rows(args,_sel,&block) end end |
#rows_(*args, &block) ⇒ Object
156 157 158 159 |
# File 'lib/rio/context/stream.rb', line 156 def rows_(*args,&block) _set_sstype('rows',false) _rows(args,_sel,false,&block) end |
#skip(*args, &block) ⇒ Object
43 44 45 46 47 48 49 50 51 |
# File 'lib/rio/context/skip.rb', line 43 def skip(*args,&block) if args.empty? _noarg_skip else _arg_skip(args) end each(&block) if block_given? self end |
#skipdirs(*args, &block) ⇒ Object
81 82 83 |
# File 'lib/rio/context/dir.rb', line 81 def skipdirs(*args,&block) _set_select('skipdirs',*args,&block) end |
#skipentries(*args, &block) ⇒ Object
75 76 77 |
# File 'lib/rio/context/dir.rb', line 75 def skipentries(*args,&block) _set_select('skipentries',*args,&block) end |
#skipfiles(*args, &block) ⇒ Object
78 79 80 |
# File 'lib/rio/context/dir.rb', line 78 def skipfiles(*args,&block) _set_select('skipfiles',*args,&block) end |
#skiplines(*args, &block) ⇒ Object
173 174 175 176 177 178 |
# File 'lib/rio/context/stream.rb', line 173 def skiplines(*args,&block) #p callstr('skiplines',*args) self.lines() unless args.empty? or cx.has_key?('stream_sel') _set_sstype('skiplines') _lines(args,false,&block) end |
#skipping? ⇒ Boolean
42 |
# File 'lib/rio/context/skip.rb', line 42 def skipping?() cx['skipping'] end |
#skiprecords(*args, &block) ⇒ Object
179 180 181 182 183 |
# File 'lib/rio/context/stream.rb', line 179 def skiprecords(*args,&block) self.records_() unless args.empty? or cx.has_key?('stream_sel') _set_sstype('skiprecords') _records(args,false,&block) end |
#skiprecords_(*args, &block) ⇒ Object
184 185 186 187 188 |
# File 'lib/rio/context/stream.rb', line 184 def skiprecords_(*args,&block) self.records_() unless args.empty? or cx.has_key?('stream_sel') _set_sstype('skiprecords',false) _records(args,false,false,&block) end |
#skiprows(*args, &block) ⇒ Object
189 190 191 192 193 |
# File 'lib/rio/context/stream.rb', line 189 def skiprows(*args,&block) self.rows() unless args.empty? or cx.has_key?('stream_sel') _set_sstype('skiprows') _rows(args,false,&block) end |
#split(*args, &block) ⇒ Object
67 68 69 70 71 72 73 |
# File 'lib/rio/context/methods.rb', line 67 def split(*args,&block) if args.empty? self.splitpath else self.splitlines(*args,&block) end end |
#stream_iter? ⇒ Boolean
31 |
# File 'lib/rio/context/stream.rb', line 31 def stream_iter?() cx.has_key?('stream_itertype') && !cx['nostreamenum'] end |
#sync(arg = true, &block) ⇒ Object
80 81 82 83 |
# File 'lib/rio/context/methods.rb', line 80 def sync(arg=true,&block) ioh.sync = arg unless ioh.nil? cxx('sync',arg,&block) end |
#sync? ⇒ Boolean
88 89 90 91 92 93 94 95 |
# File 'lib/rio/context/methods.rb', line 88 def sync?() setting = cxx?('sync') unless ioh.nil? actual = ioh.sync cxx_(actual) unless actual == setting end setting end |