Sha256: 43a79358ded4475c50193566480fa49494c54c53d55925d9e3c25217ae229b32
Contents?: true
Size: 2 KB
Versions: 38
Compression:
Stored size: 2 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_values: as_values, as_row: as_row) unless block key_typed_data.each do |ooze_data| values = ooze_data.values_at(*typed_header) if as_values values elsif as_row ::CSV::Row.new(values, header) else header.zip(values) end.tap(&block) 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 ||= [] # rubocop:disable Naming/MemoizedInstanceVariableName end end end end end end end
Version data entries
38 entries across 38 versions & 1 rubygems