Class: Rapid::Baps::Requests::Request

Inherits:
Object
  • Object
show all
Defined in:
lib/ury_rapid/baps/requests/request.rb

Overview

A message to be written to the BAPS server

Request objects are usually created by the Requester, either directly or via Handler objects. They capture a native BAPS command in a format slightly higher in level than the raw bytes sent to the requests queue.

Instance Method Summary collapse

Constructor Details

#initialize(command, subcode = 0) ⇒ Request

Returns a new instance of Request


12
13
14
15
16
17
18
19
# File 'lib/ury_rapid/baps/requests/request.rb', line 12

def initialize(command, subcode = 0)
  # Format is initially set up for the command and the skip-bytes
  # field.
  @format = FormatStrings::UINT16 + FormatStrings::UINT32
  @num_bytes = 0
  @payloads = []
  @command = command | subcode
end

Instance Method Details

#float32(*payloads) ⇒ Object

Internal: Attaches a 32-bit floating point number to this request.


32
33
34
# File 'lib/ury_rapid/baps/requests/request.rb', line 32

def float32(*payloads)
  fixnums(4, FormatStrings::FLOAT32, payloads)
end

#string(*strings) ⇒ Object

Adds strings to this request


37
38
39
40
# File 'lib/ury_rapid/baps/requests/request.rb', line 37

def string(*strings)
  strings.each(&method(:single_string))
  self
end

#to(queue) ⇒ Object

Internal: Sends the request to a request queue.


43
44
45
# File 'lib/ury_rapid/baps/requests/request.rb', line 43

def to(queue)
  queue.push(pack)
end

#uint16(*payloads) ⇒ Object

Internal: Attaches a 16-bit integer to this request.


22
23
24
# File 'lib/ury_rapid/baps/requests/request.rb', line 22

def uint16(*payloads)
  fixnums(2, FormatStrings::UINT16, payloads)
end

#uint32(*payloads) ⇒ Object

Internal: Attaches a 32-bit integer to this request.


27
28
29
# File 'lib/ury_rapid/baps/requests/request.rb', line 27

def uint32(*payloads)
  fixnums(4, FormatStrings::UINT32, payloads)
end