Class: Melos::Struct::Sender

Inherits:
Base
  • Object
show all
Defined in:
lib/melos/struct/structs.rb

Overview

Section 6.1

Constant Summary collapse

STRUCT =
[
  [:sender_type, :uint8],
  [:leaf_index,   :select, ->(ctx){ctx[:sender_type] == Melos::Constants::SenderType::MEMBER}, :uint32],
  [:sender_index, :select, ->(ctx){ctx[:sender_type] == Melos::Constants::SenderType::EXTERNAL}, :uint32],
]

Instance Attribute Summary collapse

Class 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

#leaf_indexObject (readonly)

Returns the value of attribute leaf_index.



611
612
613
# File 'lib/melos/struct/structs.rb', line 611

def leaf_index
  @leaf_index
end

#sender_indexObject (readonly)

Returns the value of attribute sender_index.



611
612
613
# File 'lib/melos/struct/structs.rb', line 611

def sender_index
  @sender_index
end

#sender_typeObject (readonly)

Returns the value of attribute sender_type.



611
612
613
# File 'lib/melos/struct/structs.rb', line 611

def sender_type
  @sender_type
end

Class Method Details

.create_external(sender_index) ⇒ Object



625
626
627
628
629
630
# File 'lib/melos/struct/structs.rb', line 625

def self.create_external(sender_index)
  instance = self.allocate
  instance.instance_variable_set(:@sender_type, Melos::Constants::SenderType::EXTERNAL)
  instance.instance_variable_set(:@sender_index, sender_index)
  instance
end

.create_member(leaf_index) ⇒ Object



618
619
620
621
622
623
# File 'lib/melos/struct/structs.rb', line 618

def self.create_member(leaf_index)
  instance = self.allocate
  instance.instance_variable_set(:@sender_type, Melos::Constants::SenderType::MEMBER)
  instance.instance_variable_set(:@leaf_index, leaf_index)
  instance
end