Sha256: fb9fc943a4751d4547469b6d5160a8710e36e2a216955370a38c7e18030375d9

Contents?: true

Size: 729 Bytes

Versions: 32

Compression:

Stored size: 729 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
      print "\033[5 q"
    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

32 entries across 32 versions & 1 rubygems

Version Path
arql-0.4.11 lib/arql/vd.rb
arql-0.4.10 lib/arql/vd.rb
arql-0.4.8 lib/arql/vd.rb
arql-0.4.7 lib/arql/vd.rb
arql-0.4.6 lib/arql/vd.rb
arql-0.4.3 lib/arql/vd.rb
arql-0.4.2 lib/arql/vd.rb
arql-0.4.1 lib/arql/vd.rb
arql-0.4.0 lib/arql/vd.rb
arql-0.3.31 lib/arql/vd.rb
arql-0.3.30 lib/arql/vd.rb
arql-0.3.29 lib/arql/vd.rb
arql-0.3.28 lib/arql/vd.rb
arql-0.3.27 lib/arql/vd.rb
arql-0.3.26 lib/arql/vd.rb
arql-0.3.25 lib/arql/vd.rb
arql-0.3.24 lib/arql/vd.rb
arql-0.3.23 lib/arql/vd.rb
arql-0.3.22 lib/arql/vd.rb
arql-0.3.21 lib/arql/vd.rb