Sha256: 586ec700cb9b80be504abc6bfd14a93c7185301a7e745d5eae79c30138a0e57d
Contents?: true
Size: 1.97 KB
Versions: 50
Compression:
Stored size: 1.97 KB
Contents
module Eco module API class UseCases class OozeSamples module Helpers # Class to ease the export process class ExportableRegister attr_reader :options include Eco::API::UseCases::OozeSamples::Helpers::OozeHandlers include Enumerable def initialize(**options) @options = options.merge({ delimiter: "\n", only_indexed: true, only_labeled: true, only_with_ref: true }) end def add_ooze(ooze) ooz = ExportableOoze.new(ooze, **options) data = ooz.key_typed_data @typed_header = merge_arrays(data.keys, typed_header) key_typed_data << data end def empty? count < 1 end def each(as_values: true, as_row: false, &block) return to_enum(:each, as_row: as_row) unless block key_typed_data.each do |ooze_data| values = ooze_data.values_at(*typed_header) case when as_values values when as_row ::CSV::Row.new(values, header) else header.zip(values) end.tap do |out| yield(out) end end end def header(refresh: false) return @header if instance_variable_defined?(:@header) && !refresh @header = typed_header.map do |name| ExportableOoze.key_to_label(name) end end private def typed_header @typed_header ||= [] end def key_typed_data @typed_keyed_data ||= [] end end end end end end end
Version data entries
50 entries across 50 versions & 1 rubygems