Module: Extractor
- Included in:
- PyaExtractor, SampleExtractor, UKP5Extractor
- Defined in:
- lib/batch_experiment/extractor.rb
Class Method Summary collapse
-
.get_field(lines, field) ⇒ Object
For when there’s a field whose value is after ‘<field>: ’.
-
.get_hfield(lines, field) ⇒ Object
For when there’s a field whose value is in the next line.
Instance Method Summary collapse
- #extract(content) ⇒ Object
-
#extract_from_lines(lines) ⇒ Object
Extract an array of values from the command output.
-
#names ⇒ Object
Return the field names for each of the elements returned by extract.
Class Method Details
.get_field(lines, field) ⇒ Object
For when there’s a field whose value is after ‘<field>: ’.
3 4 5 6 |
# File 'lib/batch_experiment/extractor.rb', line 3 def self.get_field(lines, field) lines.grep(/^#{field}: .*/).each { | l | return l.match(/:[\t ]+(.*)/)[1] } '' end |
.get_hfield(lines, field) ⇒ Object
For when there’s a field whose value is in the next line.
9 10 11 |
# File 'lib/batch_experiment/extractor.rb', line 9 def self.get_hfield(lines, field) if ix = lines.find_index(field) then lines[ix + 1] else '' end end |
Instance Method Details
#extract(content) ⇒ Object
19 20 21 |
# File 'lib/batch_experiment/extractor.rb', line 19 def extract(content) extract_from_lines(content.lines.map! { | l | l.chomp! }) end |
#extract_from_lines(lines) ⇒ Object
Extract an array of values from the command output. This array has the same size as the one returned by field_names.
25 26 27 |
# File 'lib/batch_experiment/extractor.rb', line 25 def extract_from_lines(lines) fail 'This method should have been overwritten by a subclass.' end |
#names ⇒ Object
Return the field names for each of the elements returned by extract. Ex.: [‘Time’, ‘Max Mem Use’, ‘opt’, … ]
15 16 17 |
# File 'lib/batch_experiment/extractor.rb', line 15 def names fail 'This method should have been overwritten by a subclass.' end |