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.
7 8 9 10 |
# File 'lib/sdn/cli/mqtt/group.rb', line 7 def initialize(*) members.each { |k| self[k] = :nil } super end |
Instance Attribute Details
#addr ⇒ Object
Returns the value of attribute addr
6 7 8 |
# File 'lib/sdn/cli/mqtt/group.rb', line 6 def addr @addr end |
#bridge ⇒ Object
Returns the value of attribute bridge
6 7 8 |
# File 'lib/sdn/cli/mqtt/group.rb', line 6 def bridge @bridge end |
#ip ⇒ Object
Returns the value of attribute ip
6 7 8 |
# File 'lib/sdn/cli/mqtt/group.rb', line 6 def ip @ip end |
#last_direction ⇒ Object
Returns the value of attribute last_direction
6 7 8 |
# File 'lib/sdn/cli/mqtt/group.rb', line 6 def last_direction @last_direction end |
#motors ⇒ Object
Returns the value of attribute motors
6 7 8 |
# File 'lib/sdn/cli/mqtt/group.rb', line 6 def motors @motors end |
#position_percent ⇒ Object
Returns the value of attribute position_percent
6 7 8 |
# File 'lib/sdn/cli/mqtt/group.rb', line 6 def position_percent @position_percent end |
#position_pulses ⇒ Object
Returns the value of attribute position_pulses
6 7 8 |
# File 'lib/sdn/cli/mqtt/group.rb', line 6 def position_pulses @position_pulses end |
#state ⇒ Object
Returns the value of attribute state
6 7 8 |
# File 'lib/sdn/cli/mqtt/group.rb', line 6 def state @state end |
Instance Method Details
#motor_objects ⇒ Object
23 24 25 |
# File 'lib/sdn/cli/mqtt/group.rb', line 23 def motor_objects bridge.motors.select { |_addr, motor| motor.groups_string.include?(printed_addr) }.values end |
#motors_string ⇒ Object
27 28 29 |
# File 'lib/sdn/cli/mqtt/group.rb', line 27 def motors_string motor_objects.map { |m| Message.print_address(Message.parse_address(m.addr)) }.sort.join(",") end |
#printed_addr ⇒ Object
19 20 21 |
# File 'lib/sdn/cli/mqtt/group.rb', line 19 def printed_addr Message.print_address(Message.parse_address(addr)) end |
#publish(attribute, value) ⇒ Object
12 13 14 15 16 17 |
# File 'lib/sdn/cli/mqtt/group.rb', line 12 def publish(attribute, value) return unless self[attribute] != value bridge.publish("#{addr}/#{attribute.to_s.tr("_", "-")}", value.to_s) self[attribute] = value end |