Class: Stenohttp2::Common::Message
- Inherits:
-
Object
- Object
- Stenohttp2::Common::Message
- Extended by:
- T::Sig
- Defined in:
- lib/stenohttp2/common/message.rb
Constant Summary collapse
- SLICE_SIZE =
Messages are split into chunks of length 8
8
Instance Attribute Summary collapse
-
#encoded ⇒ Object
readonly
Returns the value of attribute encoded.
Instance Method Summary collapse
- #compress(text) ⇒ Object
-
#initialize(content, protocol = Stenohttp2::Common::Protocol) ⇒ Message
constructor
A new instance of Message.
- #parts ⇒ Object
Constructor Details
#initialize(content, protocol = Stenohttp2::Common::Protocol) ⇒ Message
Returns a new instance of Message.
13 14 15 |
# File 'lib/stenohttp2/common/message.rb', line 13 def initialize(content, protocol = Stenohttp2::Common::Protocol) @encoded = protocol.new.encode(content) end |
Instance Attribute Details
#encoded ⇒ Object (readonly)
Returns the value of attribute encoded.
27 28 29 |
# File 'lib/stenohttp2/common/message.rb', line 27 def encoded @encoded end |
Instance Method Details
#compress(text) ⇒ Object
23 24 25 |
# File 'lib/stenohttp2/common/message.rb', line 23 def compress(text) text.chars.each_slice(SLICE_SIZE).to_a.map(&:join).map { |r| r.ljust(SLICE_SIZE) } end |
#parts ⇒ Object
18 19 20 |
# File 'lib/stenohttp2/common/message.rb', line 18 def parts compress(encoded) end |