Class: SDN::Message::SetMotorDirection

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

Constant Summary collapse

MSG =
0x12
PARAMS_LENGTH =
1
DIRECTION =
{ standard: 0x00, reversed: 0x01 }.freeze

Instance Attribute Summary collapse

Attributes inherited from SDN::Message

#ack_requested, #dest, #node_type, #src

Instance Method Summary collapse

Methods inherited from SDN::Message

#==, #class_inspect, 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(dest = nil, direction = :standard, **kwargs) ⇒ SetMotorDirection

Returns a new instance of SetMotorDirection.



75
76
77
78
79
# File 'lib/sdn/message/set.rb', line 75

def initialize(dest = nil, direction = :standard, **kwargs)
  kwargs[:dest] ||= dest
  super(**kwargs)
  self.direction = direction
end

Instance Attribute Details

#directionObject

Returns the value of attribute direction.



73
74
75
# File 'lib/sdn/message/set.rb', line 73

def direction
  @direction
end

Instance Method Details

#paramsObject



91
92
93
# File 'lib/sdn/message/set.rb', line 91

def params
  transform_param(DIRECTION[direction])
end

#parse(params) ⇒ Object



81
82
83
84
# File 'lib/sdn/message/set.rb', line 81

def parse(params)
  super
  self.direction = DIRECTION.invert[to_number(params[0])]
end