Sha256: eb8d3d30a5b1d2e7662f410ef44d4d6037d59c8f945d63a02d75098885ac466f

Contents?: true

Size: 706 Bytes

Versions: 2

Compression:

Stored size: 706 Bytes

Contents

require 'csv'

module Arql
  class VD
    COMMAND = 'vd'

    attr_accessor :rows

    def initialize
      return unless check_command_installation
      @rows = []
      yield self
      command = "#{COMMAND} -f csv"
      IO.popen(command, 'w+') do |io|
        io.puts(csv)
        io.close_write
      end
    end

    def <<(row)
      rows << row
    end

    def csv
      CSV.generate do |csv|
        rows.each do |row|
          csv << row
        end
      end
    end

    def check_command_installation
      `which #{COMMAND}`
      if $?.exitstatus != 0
        puts "Please install vd (visidata) command, see: https://www.visidata.org/"
      else
        true
      end
    end
  end
end

Version data entries

2 entries across 2 versions & 1 rubygems

Version Path
arql-0.3.7 lib/arql/vd.rb
arql-0.3.6 lib/arql/vd.rb