Class: Biryani::Frame::Ping

Inherits:
Object
  • Object
show all
Defined in:
lib/biryani/frame/ping.rb

Instance Attribute Summary collapse

Class Method Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(ack, stream_id, opaque) ⇒ Ping

Returns a new instance of Ping.

Parameters:

  • ack (Boolean)
  • stream_id (Integer)
  • opaque (String)


9
10
11
12
13
14
# File 'lib/biryani/frame/ping.rb', line 9

def initialize(ack, stream_id, opaque)
  @f_type = FrameType::PING
  @ack = ack
  @stream_id = stream_id
  @opaque = opaque
end

Instance Attribute Details

#f_typeObject (readonly)

Returns the value of attribute f_type.



4
5
6
# File 'lib/biryani/frame/ping.rb', line 4

def f_type
  @f_type
end

#opaqueObject (readonly)

Returns the value of attribute opaque.



4
5
6
# File 'lib/biryani/frame/ping.rb', line 4

def opaque
  @opaque
end

#stream_idObject (readonly)

Returns the value of attribute stream_id.



4
5
6
# File 'lib/biryani/frame/ping.rb', line 4

def stream_id
  @stream_id
end

Class Method Details

.read(s, flags, stream_id) ⇒ Ping

Parameters:

  • s (String)
  • flags (Integer)
  • stream_id (Integer)

Returns:



39
40
41
42
43
44
# File 'lib/biryani/frame/ping.rb', line 39

def self.read(s, flags, stream_id)
  return ConnectionError.new(ErrorCode::FRAME_SIZE_ERROR, 'PING payload length MUST be 8') if s.bytesize != 8

  ack = Frame.read_ack(flags)
  Ping.new(ack, stream_id, s)
end

Instance Method Details

#ack?Boolean

Returns:

  • (Boolean)


17
18
19
# File 'lib/biryani/frame/ping.rb', line 17

def ack?
  @ack
end

#lengthInteger

Returns:

  • (Integer)


22
23
24
# File 'lib/biryani/frame/ping.rb', line 22

def length
  8
end

#to_binary_sString

Returns:

  • (String)


27
28
29
30
31
32
# File 'lib/biryani/frame/ping.rb', line 27

def to_binary_s
  payload_length = length
  flags = Frame.to_flags(ack: ack?)

  Frame.to_binary_s_header(payload_length, @f_type, flags, @stream_id) + opaque
end