Class: Melos::Struct::Base
- Inherits:
-
Object
- Object
- Melos::Struct::Base
- Defined in:
- lib/melos/struct/base.rb
Direct Known Subclasses
Add, AuthenticatedContent, Capabilities, Certificate, Commit, ConfirmedTranscriptHashInput, Credential, EncryptContext, EncryptedGroupSecrets, Extension, ExternalInit, ExternalPub, ExternalSender, FramedContent, FramedContentAuthData, GroupContext, GroupContextExtensions, GroupInfo, GroupInfoTBS, GroupSecrets, HPKECipherText, InterimTranscriptHashInput, KDFLabel, KeyPackage, KeyPackageTBS, LeafNode, LeafNodeHashInput, Lifetime, MLSMessage, Node, PSKLabel, ParentHashInput, ParentNode, ParentNodeHashInput, PathSecret, PreSharedKey, PreSharedKeyID, PrivateMessage, PrivateMessageContent, Proposal, ProposalOrRef, PublicMessage, ReInit, RefHashInput, Remove, RequiredCapabilities, Sender, SenderData, TreeHashInput, Update, UpdatePath, UpdatePathNode, Welcome
Instance Method Summary collapse
-
#deserialize_select_elem_with_context(stream, context, predicate, type, type_param) ⇒ Object
context here takes a hash returns the deserialized value value could return nil, which means predicate was not applicable predicate takes the context and returns true or false.
-
#initialize(stream) ⇒ Base
constructor
A new instance of Base.
- #raw ⇒ Object
Constructor Details
#initialize(stream) ⇒ Base
Returns a new instance of Base.
4 5 6 7 8 9 |
# File 'lib/melos/struct/base.rb', line 4 def initialize(stream) stream = StringIO.new(stream) if stream.is_a?(String) context = deserialize(stream) set_instance_vars(context) self end |
Instance Method Details
#deserialize_select_elem_with_context(stream, context, predicate, type, type_param) ⇒ Object
context here takes a hash returns the deserialized value value could return nil, which means predicate was not applicable predicate takes the context and returns true or false
30 31 32 33 34 35 36 |
# File 'lib/melos/struct/base.rb', line 30 def deserialize_select_elem_with_context(stream, context, predicate, type, type_param) if predicate.(context) deserialize_elem(stream, type, type_param) else nil end end |
#raw ⇒ Object
11 12 13 14 15 16 17 18 19 20 21 22 23 24 |
# File 'lib/melos/struct/base.rb', line 11 def raw buf = '' self.class::STRUCT.each do |elem| case elem[1] when :select value = self.instance_variable_get("@#{elem[0]}") buf += serialize_select_elem(value, elem[3]) else value = self.instance_variable_get("@#{elem[0]}") buf += serialize_elem(value, elem[1], elem[2]) end end buf end |