Sha256: c0c4d2b565f19dbd935a291f6c2f2ee1923acc11b605747f3262b4139253820f

Contents?: true

Size: 734 Bytes

Versions: 4

Compression:

Stored size: 734 Bytes

Contents

require 'csv'

module PryHelper
  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

4 entries across 4 versions & 1 rubygems

Version Path
pry-helper-0.1.3 lib/pry-helper/vd.rb
pry-helper-0.1.2 lib/pry-helper/vd.rb
pry-helper-0.1.1 lib/pry-helper/vd.rb
pry-helper-0.1.0 lib/pry-helper/vd.rb