Files
danbooru/app/logical/iqdb/command.rb
2014-03-26 17:20:34 -07:00

30 lines
537 B
Ruby

module Iqdb
class Command
attr_reader :database
def initialize(database)
@database = database
end
def process(&block)
IO.popen("iqdb command #{database}", "w", &block)
end
def add(post)
hex = post.id.to_s(16)
process do |io|
io.puts "add 0 #{hex}:#{post.preview_file_path}"
io.puts "quit"
end
end
def remove(post_id)
hex = post_id.to_s(16)
process do |io|
io.puts "remove 0 #{hex}"
io.puts "quit"
end
end
end
end