class SDN::Message::Lock
Constants
- MSG
- PARAMS_LENGTH
- TARGET_TYPE
Attributes
priority[R]
target[R]
target_type[R]
Public Class Methods
new(dest = nil, target_type = :unlock, target = nil, priority = 1, **kwargs)
click to toggle source
Calls superclass method
SDN::Message::new
# File lib/sdn/message/control.rb, line 10 def initialize(dest = nil, target_type = :unlock, target = nil, priority = 1, **kwargs) kwargs[:dest] ||= dest super(**kwargs) self.target_type = target_type self.target = target self.priority = priority end
Public Instance Methods
params()
click to toggle source
# File lib/sdn/message/control.rb, line 39 def params transform_param(TARGET_TYPE[target_type]) + from_number(target, 2) + transform_param(priority) + transform_param(0) end
parse(params)
click to toggle source
Calls superclass method
SDN::Message::parse
# File lib/sdn/message/control.rb, line 31 def parse(params) super self.target_type = TARGET_TYPE.invert[to_number(params[0])] target = to_number(params[1..2], nillable: true) self.target = target self.priority = to_number(params[3]) end
priority=(value)
click to toggle source
# File lib/sdn/message/control.rb, line 27 def priority=(value) @priority = value & 0xff end
target=(value)
click to toggle source
# File lib/sdn/message/control.rb, line 23 def target=(value) @target = value&. & 0xffff end
target_type=(value)
click to toggle source
# File lib/sdn/message/control.rb, line 18 def target_type=(value) raise ArgumentError, "target_type must be one of :current, :up_limit, :down_limit, :ip, :unlock, or :position_percent" unless TARGET_TYPE.keys.include?(value) @target_type = value end