Class: Melos::Struct::PrivateMessageContent
- Defined in:
- lib/melos/struct/structs.rb
Instance Attribute Summary collapse
-
#application_data ⇒ Object
Returns the value of attribute application_data.
-
#auth ⇒ Object
Returns the value of attribute auth.
-
#commit ⇒ Object
Returns the value of attribute commit.
-
#padding ⇒ Object
Returns the value of attribute padding.
-
#proposal ⇒ Object
Returns the value of attribute proposal.
Class Method Summary collapse
-
.new_with_content_type(stream, content_type) ⇒ Object
bytes -> struct: decode the content and auth field, rest is padding struct -> bytes: encode content and auth field, add set amount of padding (zero bytes).
Instance Method Summary collapse
Methods inherited from Base
#deserialize_select_elem_with_context, #initialize, #raw
Constructor Details
This class inherits a constructor from Melos::Struct::Base
Instance Attribute Details
#application_data ⇒ Object
Returns the value of attribute application_data.
945 946 947 |
# File 'lib/melos/struct/structs.rb', line 945 def application_data @application_data end |
#auth ⇒ Object
Returns the value of attribute auth.
945 946 947 |
# File 'lib/melos/struct/structs.rb', line 945 def auth @auth end |
#commit ⇒ Object
Returns the value of attribute commit.
945 946 947 |
# File 'lib/melos/struct/structs.rb', line 945 def commit @commit end |
#padding ⇒ Object
Returns the value of attribute padding.
945 946 947 |
# File 'lib/melos/struct/structs.rb', line 945 def padding @padding end |
#proposal ⇒ Object
Returns the value of attribute proposal.
945 946 947 |
# File 'lib/melos/struct/structs.rb', line 945 def proposal @proposal end |
Class Method Details
.new_with_content_type(stream, content_type) ⇒ Object
bytes -> struct: decode the content and auth field, rest is padding struct -> bytes: encode content and auth field, add set amount of padding (zero bytes)
949 950 951 952 953 954 955 956 957 958 959 960 961 962 963 964 965 966 967 968 969 970 |
# File 'lib/melos/struct/structs.rb', line 949 def self.new_with_content_type(stream, content_type) instance = self.allocate context = [] # deserialize application_data/proposal/commit case content_type when Melos::Constants::ContentType::APPLICATION value = Melos::Vec.parse_stringio(stream) context << [:application_data, value] when Melos::Constants::ContentType::PROPOSAL value = Melos::Struct::Proposal.new(stream) context << [:proposal, value] when Melos::Constants::ContentType::COMMIT value = Melos::Struct::Commit.new(stream) context << [:commit, value] end fcad = Melos::Struct::FramedContentAuthData.new_with_content_type(stream, content_type) context << [:auth, fcad] # assume rest is padding context << [:padding, stream.read()] instance.send(:set_instance_vars, context) instance end |
Instance Method Details
#content ⇒ Object
972 973 974 |
# File 'lib/melos/struct/structs.rb', line 972 def content @application_data || @proposal || @commit end |