Class: SDN::Message::PostGroupAddr

Inherits:
SDN::Message show all
Defined in:
lib/sdn/message/post.rb

Constant Summary collapse

MSG =
0x61
PARAMS_LENGTH =
4

Instance Attribute Summary collapse

Attributes inherited from SDN::Message

#ack_requested, #dest, #node_type, #src

Instance Method Summary collapse

Methods inherited from SDN::Message

#==, expected_response?, inherited, #inspect, parse, #serialize

Methods included from Helpers

#checksum, #from_number, #from_string, #is_group_address?, #node_type_from_number, #node_type_to_number, #node_type_to_string, #parse_address, #print_address, #to_number, #to_string, #transform_param

Constructor Details

#initialize(group_index = nil, group_address = nil, **kwargs) ⇒ PostGroupAddr

Returns a new instance of PostGroupAddr.



7
8
9
10
11
# File 'lib/sdn/message/post.rb', line 7

def initialize(group_index = nil, group_address = nil, **kwargs)
  super(**kwargs)
  self.group_index = group_index
  self.group_address = group_address
end

Instance Attribute Details

#group_addressObject

Returns the value of attribute group_address.



13
14
15
# File 'lib/sdn/message/post.rb', line 13

def group_address
  @group_address
end

#group_indexObject

Returns the value of attribute group_index.



13
14
15
# File 'lib/sdn/message/post.rb', line 13

def group_index
  @group_index
end

Instance Method Details

#class_inspectObject



26
27
28
# File 'lib/sdn/message/post.rb', line 26

def class_inspect
  ", group_index=#{group_index.inspect}, group_address=#{group_address ? print_address(group_address) : 'nil'}"
end

#paramsObject



22
23
24
# File 'lib/sdn/message/post.rb', line 22

def params
  from_number(group_index - 1) + transform_param(group_address || [0, 0, 0])
end

#parse(params) ⇒ Object



15
16
17
18
19
20
# File 'lib/sdn/message/post.rb', line 15

def parse(params)
  super
  self.group_index = to_number(params[0]) + 1
  self.group_address = transform_param(params[1..3])
  self.group_address = nil if group_address == [0, 0, 0] || group_address == [0x01, 0x01, 0xff]
end