Class: Neh::Cli::O

Inherits:
Object
  • Object
show all
Defined in:
lib/neh/cli/o.rb

Overview

rubocop:disable Metrics/ClassLength

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(*args, options:) ⇒ O

Returns a new instance of O.



16
17
18
19
20
21
22
# File 'lib/neh/cli/o.rb', line 16

def initialize(*args, options:)
  @message = args.join(' ')
  @options = options
  @message_pool = {}
  @expected_sequence_number = 1
  @uuid = SecureRandom.uuid
end

Instance Attribute Details

#uuidObject (readonly)

Returns the value of attribute uuid.



14
15
16
# File 'lib/neh/cli/o.rb', line 14

def uuid
  @uuid
end

Instance Method Details

#executeObject



24
25
26
27
28
29
30
31
32
33
# File 'lib/neh/cli/o.rb', line 24

def execute
  Async::WebSocket::Client.connect(endpoint, headers: { 'Authorization' => "Bearer #{token}" }) do |connection|
    while (message = connection.read)
      parsed_message =
        JSON.parse(message, symbolize_names: true)

      on_receive(connection, parsed_message)
    end
  end
end