Class: Biryani::Frame::Priority
- Inherits:
-
Object
- Object
- Biryani::Frame::Priority
- Defined in:
- lib/biryani/frame/priority.rb
Instance Attribute Summary collapse
-
#f_type ⇒ Object
readonly
Returns the value of attribute f_type.
-
#stream_dependency ⇒ Object
readonly
Returns the value of attribute stream_dependency.
-
#stream_id ⇒ Object
readonly
Returns the value of attribute stream_id.
-
#weight ⇒ Object
readonly
Returns the value of attribute weight.
Class Method Summary collapse
Instance Method Summary collapse
-
#initialize(stream_id, stream_dependency, weight) ⇒ Priority
constructor
A new instance of Priority.
- #length ⇒ Integer
- #to_binary_s ⇒ String
Constructor Details
#initialize(stream_id, stream_dependency, weight) ⇒ Priority
Returns a new instance of Priority.
9 10 11 12 13 14 |
# File 'lib/biryani/frame/priority.rb', line 9 def initialize(stream_id, stream_dependency, weight) @f_type = FrameType::PRIORITY @stream_id = stream_id @stream_dependency = stream_dependency @weight = weight end |
Instance Attribute Details
#f_type ⇒ Object (readonly)
Returns the value of attribute f_type.
4 5 6 |
# File 'lib/biryani/frame/priority.rb', line 4 def f_type @f_type end |
#stream_dependency ⇒ Object (readonly)
Returns the value of attribute stream_dependency.
4 5 6 |
# File 'lib/biryani/frame/priority.rb', line 4 def stream_dependency @stream_dependency end |
#stream_id ⇒ Object (readonly)
Returns the value of attribute stream_id.
4 5 6 |
# File 'lib/biryani/frame/priority.rb', line 4 def stream_id @stream_id end |
#weight ⇒ Object (readonly)
Returns the value of attribute weight.
4 5 6 |
# File 'lib/biryani/frame/priority.rb', line 4 def weight @weight end |
Class Method Details
.read(s, _flags, stream_id) ⇒ Priority
34 35 36 37 38 39 40 41 42 |
# File 'lib/biryani/frame/priority.rb', line 34 def self.read(s, _flags, stream_id) return ConnectionError.new(ErrorCode::FRAME_SIZE_ERROR, 'PRIORITY payload length MUST be 5') if s.bytesize != 5 stream_dependency, weight = s.unpack('NC') stream_dependency %= 2**31 return ConnectionError.new(ErrorCode::PROTOCOL_ERROR, 'cannot depend on itself') if stream_dependency == stream_id Priority.new(stream_id, stream_dependency, weight) end |
Instance Method Details
#length ⇒ Integer
17 18 19 |
# File 'lib/biryani/frame/priority.rb', line 17 def length 5 end |
#to_binary_s ⇒ String
22 23 24 25 26 27 |
# File 'lib/biryani/frame/priority.rb', line 22 def to_binary_s payload_length = length flags = 0x00 Frame.to_binary_s_header(payload_length, @f_type, flags, @stream_id) + [@stream_dependency, @weight].pack('NC') end |