Class: Arql::VD
Constant Summary collapse
- COMMAND =
'vd'
Instance Attribute Summary collapse
-
#rows ⇒ Object
Returns the value of attribute rows.
Instance Method Summary collapse
- #<<(row) ⇒ Object
- #check_command_installation ⇒ Object
- #csv ⇒ Object
-
#initialize {|_self| ... } ⇒ VD
constructor
A new instance of VD.
Constructor Details
#initialize {|_self| ... } ⇒ VD
Returns a new instance of VD.
9 10 11 12 13 14 15 16 17 18 19 |
# File 'lib/arql/vd.rb', line 9 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 |
Instance Attribute Details
#rows ⇒ Object
Returns the value of attribute rows.
7 8 9 |
# File 'lib/arql/vd.rb', line 7 def rows @rows end |
Instance Method Details
#<<(row) ⇒ Object
21 22 23 |
# File 'lib/arql/vd.rb', line 21 def <<(row) rows << row end |
#check_command_installation ⇒ Object
33 34 35 36 37 38 39 40 |
# File 'lib/arql/vd.rb', line 33 def check_command_installation `which #{COMMAND}` if $?.exitstatus != 0 puts "Please install vd (visidata) command, see: https://www.visidata.org/" else true end end |
#csv ⇒ Object
25 26 27 28 29 30 31 |
# File 'lib/arql/vd.rb', line 25 def csv CSV.generate do |csv| rows.each do |row| csv << row end end end |