Class: CTioga2::Data::Backends::TextBackend
- Includes:
- Dobjects
- Defined in:
- lib/ctioga2/data/backends/backends/text.rb
Constant Summary collapse
- UNCOMPRESSORS =
A constant holding a relation extension -> command to decompress (to be fed to sprintf with the filename as argument)
{ ".gz" => "gunzip -c %s", ".bz2" => "bunzip2 -c %s", ".lzma" => "unlzma -c %s", ".lz" => "unlzma -c %s", }
Instance Method Summary collapse
-
#expand_sets(spec) ⇒ Object
Expands specifications into few sets.
- #extend(mod) ⇒ Object
-
#initialize ⇒ TextBackend
constructor
param_accessor :select, ‘select’, “Select lines”, => :string, “Skips line where the code returns false”.
Methods inherited from Backend
#dataset, describe, #description, #has_set?, list_backends, #set_param_from_string, #sets_available
Methods included from BackendDescriptionExtend
#base_description, #create_factory, #describe, #description, #factory_class, #factory_description, #factory_description_hash, #factory_description_list, #has_factory?, #inherit_parameters, #param, #param_accessor, #param_reader, #param_writer, #register_class, #set_description
Methods included from Log
debug, error, fatal, #format_exception, #identify, info, init_logger, logger, set_level, #spawn, warn
Constructor Details
#initialize ⇒ TextBackend
param_accessor :select, ‘select’, “Select lines”, => :string,
"Skips line where the code returns false"
83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 |
# File 'lib/ctioga2/data/backends/backends/text.rb', line 83 def initialize @dummy = nil @current = nil # Current is the name of the last file used. Necessary for '' specs. @current_data = nil # The data of the last file used. @skip = 0 @included_modules = [NaN] # to make sure we give them to # Dvector.compute_formula @default_column_spec = "1:2" @separator = /\s+/ # We don't split data by default. @split = false super() # Override Backend's cache - for now. @cache = {} # A cache file_name -> data end |
Instance Method Details
#expand_sets(spec) ⇒ Object
Expands specifications into few sets. This function will separate the set into a file spec and a col spec. Within the col spec, the 2##6 keyword is used to expand to 2,3,4,5,6. 2## followed by a non-digit expands to 2,…,last column in the file. For now, the expansions stops on the first occurence found, and the second form doesn’t work yet. But soon…
116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 |
# File 'lib/ctioga2/data/backends/backends/text.rb', line 116 def (spec) if m = /(\d+)##(\D|$)/.match(spec) a = m[1].to_i trail = m[2] b = read_file(spec) b = (b.length - 1) ret = [] a.upto(b) do |i| ret << m.pre_match + i.to_s + trail + m.post_match end return ret else return super end end |
#extend(mod) ⇒ Object
105 106 107 108 |
# File 'lib/ctioga2/data/backends/backends/text.rb', line 105 def extend(mod) super @included_modules << mod end |