Class: Biryani::Frame::Continuation

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

Instance Attribute Summary collapse

Class Method Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(end_headers, stream_id, fragment) ⇒ Continuation

Returns a new instance of Continuation.

Parameters:

  • end_headers (Boolean)
  • stream_id (Integer)
  • fragment (String)


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

def initialize(end_headers, stream_id, fragment)
  @f_type = FrameType::CONTINUATION
  @end_headers = end_headers
  @stream_id = stream_id
  @fragment = fragment
end

Instance Attribute Details

#f_typeObject (readonly)

Returns the value of attribute f_type.



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

def f_type
  @f_type
end

#fragmentObject (readonly)

Returns the value of attribute fragment.



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

def fragment
  @fragment
end

#stream_idObject (readonly)

Returns the value of attribute stream_id.



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

def stream_id
  @stream_id
end

Class Method Details

.read(s, flags, stream_id) ⇒ Continuation

Parameters:

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

Returns:



39
40
41
42
# File 'lib/biryani/frame/continuation.rb', line 39

def self.read(s, flags, stream_id)
  end_headers = Frame.read_end_headers(flags)
  Continuation.new(end_headers, stream_id, s)
end

Instance Method Details

#end_headers?Boolean

Returns:

  • (Boolean)


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

def end_headers?
  @end_headers
end

#lengthInteger

Returns:

  • (Integer)


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

def length
  @fragment.bytesize
end

#to_binary_sString

Returns:

  • (String)


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

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

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