Class: SDN::CLI::MQTT::Group
- Inherits:
-
Struct
- Object
- Struct
- SDN::CLI::MQTT::Group
- Defined in:
- lib/sdn/cli/mqtt/group.rb
Instance Attribute Summary collapse
-
#addr ⇒ Object
Returns the value of attribute addr.
-
#bridge ⇒ Object
Returns the value of attribute bridge.
-
#ip ⇒ Object
Returns the value of attribute ip.
-
#last_direction ⇒ Object
Returns the value of attribute last_direction.
-
#motors ⇒ Object
Returns the value of attribute motors.
-
#position_percent ⇒ Object
Returns the value of attribute position_percent.
-
#position_pulses ⇒ Object
Returns the value of attribute position_pulses.
-
#state ⇒ Object
Returns the value of attribute state.
Instance Method Summary collapse
-
#initialize ⇒ Group
constructor
A new instance of Group.
- #motor_objects ⇒ Object
- #motors_string ⇒ Object
- #printed_addr ⇒ Object
- #publish(attribute, value) ⇒ Object
Constructor Details
#initialize ⇒ Group
Returns a new instance of Group.
5 6 7 8 |
# File 'lib/sdn/cli/mqtt/group.rb', line 5 def initialize(*) members.each { |k| self[k] = :nil } super end |
Instance Attribute Details
#addr ⇒ Object
Returns the value of attribute addr
4 5 6 |
# File 'lib/sdn/cli/mqtt/group.rb', line 4 def addr @addr end |
#bridge ⇒ Object
Returns the value of attribute bridge
4 5 6 |
# File 'lib/sdn/cli/mqtt/group.rb', line 4 def bridge @bridge end |
#ip ⇒ Object
Returns the value of attribute ip
4 5 6 |
# File 'lib/sdn/cli/mqtt/group.rb', line 4 def ip @ip end |
#last_direction ⇒ Object
Returns the value of attribute last_direction
4 5 6 |
# File 'lib/sdn/cli/mqtt/group.rb', line 4 def last_direction @last_direction end |
#motors ⇒ Object
Returns the value of attribute motors
4 5 6 |
# File 'lib/sdn/cli/mqtt/group.rb', line 4 def motors @motors end |
#position_percent ⇒ Object
Returns the value of attribute position_percent
4 5 6 |
# File 'lib/sdn/cli/mqtt/group.rb', line 4 def position_percent @position_percent end |
#position_pulses ⇒ Object
Returns the value of attribute position_pulses
4 5 6 |
# File 'lib/sdn/cli/mqtt/group.rb', line 4 def position_pulses @position_pulses end |
#state ⇒ Object
Returns the value of attribute state
4 5 6 |
# File 'lib/sdn/cli/mqtt/group.rb', line 4 def state @state end |
Instance Method Details
#motor_objects ⇒ Object
21 22 23 |
# File 'lib/sdn/cli/mqtt/group.rb', line 21 def motor_objects bridge.motors.select { |addr, motor| motor.groups_string.include?(printed_addr) }.values end |
#motors_string ⇒ Object
25 26 27 |
# File 'lib/sdn/cli/mqtt/group.rb', line 25 def motors_string motor_objects.map { |m| Message.print_address(Message.parse_address(m.addr)) }.sort.join(',') end |
#printed_addr ⇒ Object
17 18 19 |
# File 'lib/sdn/cli/mqtt/group.rb', line 17 def printed_addr Message.print_address(Message.parse_address(addr)) end |
#publish(attribute, value) ⇒ Object
10 11 12 13 14 15 |
# File 'lib/sdn/cli/mqtt/group.rb', line 10 def publish(attribute, value) if self[attribute] != value bridge.publish("#{addr}/#{attribute.to_s.gsub('_', '-')}", value.to_s) self[attribute] = value end end |