Class: SDN::CLI::MQTT::Group
- Inherits:
-
Struct
- Object
- Struct
- SDN::CLI::MQTT::Group
- Defined in:
- lib/sdn/cli/mqtt/group.rb
Overview
In-memory state container for a discovered group and its aggregated MQTT attributes.
Instance Attribute Summary collapse
-
#addr ⇒ Object
Returns the value of attribute addr.
-
#bridge ⇒ Object
Returns the value of attribute bridge.
-
#hass_state ⇒ Object
Returns the value of attribute hass_state.
-
#ip ⇒ Object
Returns the value of attribute ip.
-
#last_direction ⇒ Object
Returns the value of attribute last_direction.
- #motor_objects ⇒ <SDN::CLI::MQTT::Motor> readonly
-
#motors ⇒ Object
Returns the value of attribute motors.
-
#motors_string ⇒ String
readonly
Returns the current group membership as a comma-separated motor address list.
-
#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.
- #printed_addr ⇒ String
Constructor Details
#initialize ⇒ Group
Returns a new instance of Group.
16 17 18 19 |
# File 'lib/sdn/cli/mqtt/group.rb', line 16 def initialize(*) members.each { |k| self[k] = :nil } super end |
Instance Attribute Details
#addr ⇒ Object
Returns the value of attribute addr
7 8 9 |
# File 'lib/sdn/cli/mqtt/group.rb', line 7 def addr @addr end |
#bridge ⇒ Object
Returns the value of attribute bridge
7 8 9 |
# File 'lib/sdn/cli/mqtt/group.rb', line 7 def bridge @bridge end |
#hass_state ⇒ Object
Returns the value of attribute hass_state
7 8 9 |
# File 'lib/sdn/cli/mqtt/group.rb', line 7 def hass_state @hass_state end |
#ip ⇒ Object
Returns the value of attribute ip
7 8 9 |
# File 'lib/sdn/cli/mqtt/group.rb', line 7 def ip @ip end |
#last_direction ⇒ Object
Returns the value of attribute last_direction
7 8 9 |
# File 'lib/sdn/cli/mqtt/group.rb', line 7 def last_direction @last_direction end |
#motor_objects ⇒ <SDN::CLI::MQTT::Motor> (readonly)
37 38 39 |
# File 'lib/sdn/cli/mqtt/group.rb', line 37 def motor_objects bridge.motors.select { |_addr, motor| motor.groups_string.include?(printed_addr) }.values end |
#motors ⇒ Object
Returns the value of attribute motors
7 8 9 |
# File 'lib/sdn/cli/mqtt/group.rb', line 7 def motors @motors end |
#motors_string ⇒ String (readonly)
Returns the current group membership as a comma-separated motor address list.
46 47 48 |
# File 'lib/sdn/cli/mqtt/group.rb', line 46 def motors_string motor_objects.map { |m| Message.print_address(Message.parse_address(m.addr)) }.sort.join(",") end |
#position_percent ⇒ Object
Returns the value of attribute position_percent
7 8 9 |
# File 'lib/sdn/cli/mqtt/group.rb', line 7 def position_percent @position_percent end |
#position_pulses ⇒ Object
Returns the value of attribute position_pulses
7 8 9 |
# File 'lib/sdn/cli/mqtt/group.rb', line 7 def position_pulses @position_pulses end |
#state ⇒ Object
Returns the value of attribute state
7 8 9 |
# File 'lib/sdn/cli/mqtt/group.rb', line 7 def state @state end |
Instance Method Details
#printed_addr ⇒ String
30 31 32 |
# File 'lib/sdn/cli/mqtt/group.rb', line 30 def printed_addr Message.print_address(Message.parse_address(addr)) end |