Class: GroqApi
- Inherits:
-
Object
- Object
- GroqApi
- Defined in:
- lib/groq_api.rb
Overview
GroqApi
Instance Attribute Summary collapse
-
#request ⇒ Object
Returns the value of attribute request.
-
#syntax_highlighter ⇒ Object
Returns the value of attribute syntax_highlighter.
Instance Method Summary collapse
- #call ⇒ Object
-
#initialize(options) ⇒ GroqApi
constructor
A new instance of GroqApi.
- #xclip_installed? ⇒ Boolean
Constructor Details
#initialize(options) ⇒ GroqApi
Returns a new instance of GroqApi.
13 14 15 16 |
# File 'lib/groq_api.rb', line 13 def initialize() @request = Request.new() @syntax_highlighter = SyntaxHighlighter.new end |
Instance Attribute Details
#request ⇒ Object
Returns the value of attribute request.
11 12 13 |
# File 'lib/groq_api.rb', line 11 def request @request end |
#syntax_highlighter ⇒ Object
Returns the value of attribute syntax_highlighter.
11 12 13 |
# File 'lib/groq_api.rb', line 11 def syntax_highlighter @syntax_highlighter end |
Instance Method Details
#call ⇒ Object
22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 |
# File 'lib/groq_api.rb', line 22 def call = request.call File.open(File.('~/.gchat.log'), 'a') do |file| file.puts("#{}\n") end # puts '' # puts message_content matches = Parser.new().parse if matches command = matches[0] else puts "\033[31m No command found in the message content. \033[0m" return end puts '' puts '' puts "\033[32m====================================== \033[0m" puts '' puts syntax_highlighter.highlight(command) puts '' puts "\033[32mrun(r) copy(o) cancel(c) \033[0m" prompt = gets.chomp exit if prompt == 'c' system(command) if prompt == 'r' if prompt == 'o' if xclip_installed? IO.popen('xclip -selection clipboard', 'w') { |f| f << command } else puts "\033[31m xclip is not installed. Please install xclip to use the copy feature. \033[0m" end end end |
#xclip_installed? ⇒ Boolean
18 19 20 |
# File 'lib/groq_api.rb', line 18 def xclip_installed? system('which xclip > /dev/null 2>&1') end |