Sha256: ca30e216ea8b63ad629e4cdbb2d9ce1e91200089f8486944b4f51590e0293657

Contents?: true

Size: 626 Bytes

Versions: 4

Compression:

Stored size: 626 Bytes

Contents

module Bmg
  module Writer

  protected

    def infer_headers(from)
      attrlist = if from.is_a?(Type) && from.knows_attrlist?
        from.to_attrlist
      elsif from.is_a?(Hash)
        from.keys
      end
      attrlist ? output_preferences.order_attrlist(attrlist) : nil
    end

    def each_tuple(relation, &bl)
      if ordering = output_preferences.tuple_ordering
        relation
          .to_a
          .sort{|t1,t2| ordering.call(t1, t2) }
          .each_with_index(&bl)
      else
        relation.each_with_index(&bl)
      end
    end

  end # module Writer
end # module Bmg
require_relative 'writer/csv'

Version data entries

4 entries across 4 versions & 1 rubygems

Version Path
bmg-0.23.3 lib/bmg/writer.rb
bmg-0.23.2 lib/bmg/writer.rb
bmg-0.23.1 lib/bmg/writer.rb
bmg-0.23.0 lib/bmg/writer.rb